@olastudio/social-media-sdk 0.1.2 → 0.2.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.
- package/dist/adapters/expo.d.mts +1 -1
- package/dist/adapters/expo.d.ts +1 -1
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/{auth.types-DTXCyA56.d.mts → auth.types-Do2L11TO.d.mts} +1 -1
- package/dist/{auth.types-DTXCyA56.d.ts → auth.types-Do2L11TO.d.ts} +1 -1
- package/dist/core/index.d.mts +128 -5
- package/dist/core/index.d.ts +128 -5
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +229 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +229 -0
- package/dist/index.mjs.map +1 -1
- package/dist/{insights.types-DF2_r0L1.d.ts → insights.types-BCalhgkj.d.ts} +1 -1
- package/dist/{insights.types-5z7HJnbt.d.mts → insights.types-hLzNJATM.d.mts} +1 -1
- package/dist/providers/facebook/index.d.mts +109 -2
- package/dist/providers/facebook/index.d.ts +109 -2
- package/dist/providers/facebook/index.js +105 -0
- package/dist/providers/facebook/index.js.map +1 -1
- package/dist/providers/facebook/index.mjs +105 -0
- package/dist/providers/facebook/index.mjs.map +1 -1
- package/dist/providers/instagram/index.d.mts +141 -3
- package/dist/providers/instagram/index.d.ts +141 -3
- package/dist/providers/instagram/index.js +124 -0
- package/dist/providers/instagram/index.js.map +1 -1
- package/dist/providers/instagram/index.mjs +124 -0
- package/dist/providers/instagram/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
|
@@ -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 {
|
|
2
|
-
import {
|
|
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
|
|
@@ -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
|