@olastudio/social-media-sdk 0.1.3 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { R as RequestOptions } from './auth.types-DTXCyA56.js';
1
+ import { R as RequestOptions } from './auth.types-Do2L11TO.js';
2
2
 
3
3
  /**
4
4
  * API Types - Interfaces for API clients
@@ -1,4 +1,4 @@
1
- import { R as RequestOptions } from './auth.types-DTXCyA56.mjs';
1
+ import { R as RequestOptions } from './auth.types-Do2L11TO.mjs';
2
2
 
3
3
  /**
4
4
  * API Types - Interfaces for API clients
@@ -1,5 +1,5 @@
1
- import { U as UserProfile, R as RequestOptions, c as AuthProvider, A as AuthResult } from '../../auth.types-DTXCyA56.mjs';
2
- import { A as APIClient, d as PageOverview, c as InsightsResponse, g as VideoInsights, i as ReelsInsights, f as PostInsights, k as PhotoInsights } from '../../insights.types-5z7HJnbt.mjs';
1
+ import { A as APIClient, d as PageOverview, c as InsightsResponse, g as VideoInsights, i as ReelsInsights, f as PostInsights, k as PhotoInsights } from '../../insights.types-hLzNJATM.mjs';
2
+ import { U as UserProfile, R as RequestOptions, A as AuthProvider, b as AuthResult } from '../../auth.types-Do2L11TO.mjs';
3
3
 
4
4
  /**
5
5
  * Facebook Types - Facebook-specific types
@@ -32,11 +32,11 @@ declare enum FacebookScopesBusiness {
32
32
  COMMERCE_ACCOUNT_READ_REPORTS = "commerce_account_read_reports",
33
33
  COMMERCE_ACCOUNT_READ_SETTINGS = "commerce_account_read_settings",
34
34
  COMMERCE_MANAGE_ACCOUNTS = "commerce_manage_accounts",
35
- INSTAGRAM_BASIC = "instagram_basic",
36
- INSTAGRAM_CONTENT_PUBLISH = "instagram_content_publish",
37
- INSTAGRAM_MANAGE_COMMENTS = "instagram_manage_comments",
38
- INSTAGRAM_MANAGE_INSIGHTS = "instagram_manage_insights",
39
- INSTAGRAM_MANAGE_MESSAGES = "instagram_manage_messages",
35
+ INSTAGRAM_BASIC = "instagram_business_basic",
36
+ INSTAGRAM_CONTENT_PUBLISH = "instagram_business_content_publish",
37
+ INSTAGRAM_MANAGE_COMMENTS = "instagram_business_manage_comments",
38
+ INSTAGRAM_MANAGE_INSIGHTS = "instagram_business_manage_insights",
39
+ INSTAGRAM_MANAGE_MESSAGES = "instagram_business_manage_messages",
40
40
  INSTAGRAM_SHOPPING_TAG_PRODUCTS = "instagram_shopping_tag_products",
41
41
  LEADS_RETRIEVAL = "leads_retrieval",
42
42
  MANAGE_APP_SOLUTIONS = "manage_app_solutions",
@@ -385,6 +385,113 @@ declare class FacebookAPI implements APIClient {
385
385
  * Get current API version (read-only)
386
386
  */
387
387
  getApiVersion(): string;
388
+ /**
389
+ * Get conversations (inbox) for a Facebook Page
390
+ * Requires `pages_messaging` permission
391
+ *
392
+ * @param pageId - Facebook Page ID
393
+ * @param options - Pagination and field options
394
+ * @returns Paginated list of conversations
395
+ */
396
+ getPageConversations(pageId: string, options?: {
397
+ limit?: number;
398
+ after?: string;
399
+ fields?: string[];
400
+ }): Promise<{
401
+ data: Array<{
402
+ id: string;
403
+ participants: {
404
+ data: Array<{
405
+ id: string;
406
+ name: string;
407
+ email?: string;
408
+ }>;
409
+ };
410
+ updated_time: string;
411
+ unread_count?: number;
412
+ snippet?: string;
413
+ can_reply?: boolean;
414
+ messages?: {
415
+ data: Array<{
416
+ id: string;
417
+ message: string;
418
+ from: {
419
+ id: string;
420
+ name: string;
421
+ };
422
+ created_time: string;
423
+ }>;
424
+ };
425
+ }>;
426
+ paging?: {
427
+ cursors?: {
428
+ before?: string;
429
+ after?: string;
430
+ };
431
+ next?: string;
432
+ };
433
+ }>;
434
+ /**
435
+ * Get messages from a specific conversation
436
+ *
437
+ * @param conversationId - Conversation ID
438
+ * @param options - Pagination options
439
+ * @returns Paginated list of messages
440
+ */
441
+ getConversationMessages(conversationId: string, options?: {
442
+ limit?: number;
443
+ after?: string;
444
+ fields?: string[];
445
+ }): Promise<{
446
+ data: Array<{
447
+ id: string;
448
+ message: string;
449
+ from: {
450
+ id: string;
451
+ name: string;
452
+ email?: string;
453
+ };
454
+ to: {
455
+ data: Array<{
456
+ id: string;
457
+ name: string;
458
+ }>;
459
+ };
460
+ created_time: string;
461
+ attachments?: {
462
+ data: Array<{
463
+ id: string;
464
+ mime_type: string;
465
+ name?: string;
466
+ file_url?: string;
467
+ image_data?: {
468
+ url: string;
469
+ };
470
+ }>;
471
+ };
472
+ }>;
473
+ paging?: {
474
+ cursors?: {
475
+ before?: string;
476
+ after?: string;
477
+ };
478
+ next?: string;
479
+ };
480
+ }>;
481
+ /**
482
+ * Send a message in a conversation
483
+ * Uses the Send API for Page messaging
484
+ *
485
+ * @param pageId - Facebook Page ID
486
+ * @param recipientId - PSID (Page-Scoped User ID) of the recipient
487
+ * @param message - Message text to send
488
+ * @param pageAccessToken - Page access token with messaging permission
489
+ * @returns Message send response
490
+ */
491
+ sendMessage(pageId: string, recipientId: string, message: string, pageAccessToken?: string): Promise<{
492
+ recipient_id: string;
493
+ message_id: string;
494
+ }>;
388
495
  }
389
496
 
390
497
  /**
@@ -1,5 +1,5 @@
1
- import { U as UserProfile, R as RequestOptions, c as AuthProvider, A as AuthResult } from '../../auth.types-DTXCyA56.js';
2
- import { A as APIClient, d as PageOverview, c as InsightsResponse, g as VideoInsights, i as ReelsInsights, f as PostInsights, k as PhotoInsights } from '../../insights.types-DF2_r0L1.js';
1
+ import { A as APIClient, d as PageOverview, c as InsightsResponse, g as VideoInsights, i as ReelsInsights, f as PostInsights, k as PhotoInsights } from '../../insights.types-BCalhgkj.js';
2
+ import { U as UserProfile, R as RequestOptions, A as AuthProvider, b as AuthResult } from '../../auth.types-Do2L11TO.js';
3
3
 
4
4
  /**
5
5
  * Facebook Types - Facebook-specific types
@@ -32,11 +32,11 @@ declare enum FacebookScopesBusiness {
32
32
  COMMERCE_ACCOUNT_READ_REPORTS = "commerce_account_read_reports",
33
33
  COMMERCE_ACCOUNT_READ_SETTINGS = "commerce_account_read_settings",
34
34
  COMMERCE_MANAGE_ACCOUNTS = "commerce_manage_accounts",
35
- INSTAGRAM_BASIC = "instagram_basic",
36
- INSTAGRAM_CONTENT_PUBLISH = "instagram_content_publish",
37
- INSTAGRAM_MANAGE_COMMENTS = "instagram_manage_comments",
38
- INSTAGRAM_MANAGE_INSIGHTS = "instagram_manage_insights",
39
- INSTAGRAM_MANAGE_MESSAGES = "instagram_manage_messages",
35
+ INSTAGRAM_BASIC = "instagram_business_basic",
36
+ INSTAGRAM_CONTENT_PUBLISH = "instagram_business_content_publish",
37
+ INSTAGRAM_MANAGE_COMMENTS = "instagram_business_manage_comments",
38
+ INSTAGRAM_MANAGE_INSIGHTS = "instagram_business_manage_insights",
39
+ INSTAGRAM_MANAGE_MESSAGES = "instagram_business_manage_messages",
40
40
  INSTAGRAM_SHOPPING_TAG_PRODUCTS = "instagram_shopping_tag_products",
41
41
  LEADS_RETRIEVAL = "leads_retrieval",
42
42
  MANAGE_APP_SOLUTIONS = "manage_app_solutions",
@@ -385,6 +385,113 @@ declare class FacebookAPI implements APIClient {
385
385
  * Get current API version (read-only)
386
386
  */
387
387
  getApiVersion(): string;
388
+ /**
389
+ * Get conversations (inbox) for a Facebook Page
390
+ * Requires `pages_messaging` permission
391
+ *
392
+ * @param pageId - Facebook Page ID
393
+ * @param options - Pagination and field options
394
+ * @returns Paginated list of conversations
395
+ */
396
+ getPageConversations(pageId: string, options?: {
397
+ limit?: number;
398
+ after?: string;
399
+ fields?: string[];
400
+ }): Promise<{
401
+ data: Array<{
402
+ id: string;
403
+ participants: {
404
+ data: Array<{
405
+ id: string;
406
+ name: string;
407
+ email?: string;
408
+ }>;
409
+ };
410
+ updated_time: string;
411
+ unread_count?: number;
412
+ snippet?: string;
413
+ can_reply?: boolean;
414
+ messages?: {
415
+ data: Array<{
416
+ id: string;
417
+ message: string;
418
+ from: {
419
+ id: string;
420
+ name: string;
421
+ };
422
+ created_time: string;
423
+ }>;
424
+ };
425
+ }>;
426
+ paging?: {
427
+ cursors?: {
428
+ before?: string;
429
+ after?: string;
430
+ };
431
+ next?: string;
432
+ };
433
+ }>;
434
+ /**
435
+ * Get messages from a specific conversation
436
+ *
437
+ * @param conversationId - Conversation ID
438
+ * @param options - Pagination options
439
+ * @returns Paginated list of messages
440
+ */
441
+ getConversationMessages(conversationId: string, options?: {
442
+ limit?: number;
443
+ after?: string;
444
+ fields?: string[];
445
+ }): Promise<{
446
+ data: Array<{
447
+ id: string;
448
+ message: string;
449
+ from: {
450
+ id: string;
451
+ name: string;
452
+ email?: string;
453
+ };
454
+ to: {
455
+ data: Array<{
456
+ id: string;
457
+ name: string;
458
+ }>;
459
+ };
460
+ created_time: string;
461
+ attachments?: {
462
+ data: Array<{
463
+ id: string;
464
+ mime_type: string;
465
+ name?: string;
466
+ file_url?: string;
467
+ image_data?: {
468
+ url: string;
469
+ };
470
+ }>;
471
+ };
472
+ }>;
473
+ paging?: {
474
+ cursors?: {
475
+ before?: string;
476
+ after?: string;
477
+ };
478
+ next?: string;
479
+ };
480
+ }>;
481
+ /**
482
+ * Send a message in a conversation
483
+ * Uses the Send API for Page messaging
484
+ *
485
+ * @param pageId - Facebook Page ID
486
+ * @param recipientId - PSID (Page-Scoped User ID) of the recipient
487
+ * @param message - Message text to send
488
+ * @param pageAccessToken - Page access token with messaging permission
489
+ * @returns Message send response
490
+ */
491
+ sendMessage(pageId: string, recipientId: string, message: string, pageAccessToken?: string): Promise<{
492
+ recipient_id: string;
493
+ message_id: string;
494
+ }>;
388
495
  }
389
496
 
390
497
  /**
@@ -875,6 +875,111 @@ var FacebookAPI = class {
875
875
  getApiVersion() {
876
876
  return FACEBOOK_GRAPH_API_VERSION;
877
877
  }
878
+ // ============= Messaging Methods =============
879
+ /**
880
+ * Get conversations (inbox) for a Facebook Page
881
+ * Requires `pages_messaging` permission
882
+ *
883
+ * @param pageId - Facebook Page ID
884
+ * @param options - Pagination and field options
885
+ * @returns Paginated list of conversations
886
+ */
887
+ async getPageConversations(pageId, options = {}) {
888
+ try {
889
+ const defaultFields = [
890
+ "id",
891
+ "participants",
892
+ "updated_time",
893
+ "unread_count",
894
+ "snippet",
895
+ "can_reply",
896
+ "messages.limit(1){id,message,from,created_time}"
897
+ ];
898
+ const params = {
899
+ fields: (options.fields || defaultFields).join(","),
900
+ limit: options.limit || 25
901
+ };
902
+ if (options.after) {
903
+ params.after = options.after;
904
+ }
905
+ const response = await this.get(`/${pageId}/conversations`, params);
906
+ return response;
907
+ } catch (error) {
908
+ throw new APIError(
909
+ `Failed to fetch page conversations: ${error instanceof Error ? error.message : "Unknown error"}`,
910
+ void 0,
911
+ "CONVERSATIONS_FETCH_ERROR",
912
+ error
913
+ );
914
+ }
915
+ }
916
+ /**
917
+ * Get messages from a specific conversation
918
+ *
919
+ * @param conversationId - Conversation ID
920
+ * @param options - Pagination options
921
+ * @returns Paginated list of messages
922
+ */
923
+ async getConversationMessages(conversationId, options = {}) {
924
+ try {
925
+ const defaultFields = [
926
+ "id",
927
+ "message",
928
+ "from",
929
+ "to",
930
+ "created_time",
931
+ "attachments"
932
+ ];
933
+ const params = {
934
+ fields: (options.fields || defaultFields).join(","),
935
+ limit: options.limit || 25
936
+ };
937
+ if (options.after) {
938
+ params.after = options.after;
939
+ }
940
+ const response = await this.get(`/${conversationId}/messages`, params);
941
+ return response;
942
+ } catch (error) {
943
+ throw new APIError(
944
+ `Failed to fetch conversation messages: ${error instanceof Error ? error.message : "Unknown error"}`,
945
+ void 0,
946
+ "MESSAGES_FETCH_ERROR",
947
+ error
948
+ );
949
+ }
950
+ }
951
+ /**
952
+ * Send a message in a conversation
953
+ * Uses the Send API for Page messaging
954
+ *
955
+ * @param pageId - Facebook Page ID
956
+ * @param recipientId - PSID (Page-Scoped User ID) of the recipient
957
+ * @param message - Message text to send
958
+ * @param pageAccessToken - Page access token with messaging permission
959
+ * @returns Message send response
960
+ */
961
+ async sendMessage(pageId, recipientId, message, pageAccessToken) {
962
+ try {
963
+ const body = {
964
+ recipient: { id: recipientId },
965
+ message: { text: message },
966
+ messaging_type: "RESPONSE",
967
+ access_token: pageAccessToken || this.accessToken
968
+ };
969
+ const response = await this.post(
970
+ `/${pageId}/messages`,
971
+ body
972
+ );
973
+ return response;
974
+ } catch (error) {
975
+ throw new APIError(
976
+ `Failed to send message: ${error instanceof Error ? error.message : "Unknown error"}`,
977
+ void 0,
978
+ "MESSAGE_SEND_ERROR",
979
+ error
980
+ );
981
+ }
982
+ }
878
983
  };
879
984
 
880
985
  // providers/facebook/auth/FacebookAuth.ts
@@ -1034,11 +1139,11 @@ var FacebookScopesBusiness = /* @__PURE__ */ ((FacebookScopesBusiness2) => {
1034
1139
  FacebookScopesBusiness2["COMMERCE_ACCOUNT_READ_REPORTS"] = "commerce_account_read_reports";
1035
1140
  FacebookScopesBusiness2["COMMERCE_ACCOUNT_READ_SETTINGS"] = "commerce_account_read_settings";
1036
1141
  FacebookScopesBusiness2["COMMERCE_MANAGE_ACCOUNTS"] = "commerce_manage_accounts";
1037
- FacebookScopesBusiness2["INSTAGRAM_BASIC"] = "instagram_basic";
1038
- FacebookScopesBusiness2["INSTAGRAM_CONTENT_PUBLISH"] = "instagram_content_publish";
1039
- FacebookScopesBusiness2["INSTAGRAM_MANAGE_COMMENTS"] = "instagram_manage_comments";
1040
- FacebookScopesBusiness2["INSTAGRAM_MANAGE_INSIGHTS"] = "instagram_manage_insights";
1041
- FacebookScopesBusiness2["INSTAGRAM_MANAGE_MESSAGES"] = "instagram_manage_messages";
1142
+ FacebookScopesBusiness2["INSTAGRAM_BASIC"] = "instagram_business_basic";
1143
+ FacebookScopesBusiness2["INSTAGRAM_CONTENT_PUBLISH"] = "instagram_business_content_publish";
1144
+ FacebookScopesBusiness2["INSTAGRAM_MANAGE_COMMENTS"] = "instagram_business_manage_comments";
1145
+ FacebookScopesBusiness2["INSTAGRAM_MANAGE_INSIGHTS"] = "instagram_business_manage_insights";
1146
+ FacebookScopesBusiness2["INSTAGRAM_MANAGE_MESSAGES"] = "instagram_business_manage_messages";
1042
1147
  FacebookScopesBusiness2["INSTAGRAM_SHOPPING_TAG_PRODUCTS"] = "instagram_shopping_tag_products";
1043
1148
  FacebookScopesBusiness2["LEADS_RETRIEVAL"] = "leads_retrieval";
1044
1149
  FacebookScopesBusiness2["MANAGE_APP_SOLUTIONS"] = "manage_app_solutions";