@olastudio/social-media-sdk 0.3.0 → 0.3.2

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,5 +1,5 @@
1
- import { A as APIClient, H as HttpClientConfig } from '../insights.types-hLzNJATM.mjs';
2
- export { p as AggregatedInsights, E as INSIGHTS_PERIODS, y as INSTAGRAM_ACCOUNT_METRICS, z as INSTAGRAM_DEMOGRAPHICS_METRICS, B as INSTAGRAM_MEDIA_METRICS_COMMON, C as INSTAGRAM_REELS_METRICS, D as INSTAGRAM_STORIES_METRICS, b as InsightBreakdown, a as InsightDataItem, I as InsightValue, q as InsightsError, F as InsightsPeriod, c as InsightsResponse, l as InstagramAccountInsightsParams, n as InstagramAccountSummary, o as InstagramMediaInsights, m as InstagramMediaInsightsParams, M as METRIC_PRESETS, r as PAGE_METRICS_LIFETIME, s as PAGE_METRICS_PERIODIC, x as PHOTO_METRICS, t as POST_METRICS, P as PageInsightsParams, d as PageOverview, k as PhotoInsights, j as PhotoInsightsParams, f as PostInsights, e as PostInsightsParams, v as REELS_METRICS, w as REELS_METRICS_EXTENDED, i as ReelsInsights, R as ReelsInsightsParams, u as VIDEO_METRICS, g as VideoInsights, V as VideoInsightsParams, h as VideoWithInsights } from '../insights.types-hLzNJATM.mjs';
1
+ import { A as APIClient, H as HttpClientConfig } from '../insights.types-BIXofwk0.mjs';
2
+ export { a as AccountInfoResponse, s as AggregatedInsights, D as DebugTokenData, b as DebugTokenResponse, K as INSIGHTS_PERIODS, C as INSTAGRAM_ACCOUNT_METRICS, E as INSTAGRAM_DEMOGRAPHICS_METRICS, F as INSTAGRAM_MEDIA_METRICS_COMMON, G as INSTAGRAM_REELS_METRICS, J as INSTAGRAM_STORIES_METRICS, d as InsightBreakdown, c as InsightDataItem, I as InsightValue, t as InsightsError, L as InsightsPeriod, e as InsightsResponse, o as InstagramAccountInsightsParams, q as InstagramAccountSummary, r as InstagramMediaInsights, p as InstagramMediaInsightsParams, M as METRIC_PRESETS, u as PAGE_METRICS_LIFETIME, v as PAGE_METRICS_PERIODIC, B as PHOTO_METRICS, w as POST_METRICS, f as PageInsightsParams, g as PageOverview, P as PagePictureResponse, n as PhotoInsights, m as PhotoInsightsParams, i as PostInsights, h as PostInsightsParams, y as REELS_METRICS, z as REELS_METRICS_EXTENDED, l as ReelsInsights, R as ReelsInsightsParams, x as VIDEO_METRICS, j as VideoInsights, V as VideoInsightsParams, k as VideoWithInsights } from '../insights.types-BIXofwk0.mjs';
3
3
  import { R as RequestOptions } from '../auth.types-Do2L11TO.mjs';
4
4
  export { d as APIErrorData, A as AuthProvider, b as AuthResult, L as LoginConfig, O as OAuthConfig, a as OAuthResult, c as PaginatedResponse, P as ProviderName, U as UserProfile } from '../auth.types-Do2L11TO.mjs';
5
5
 
@@ -1,5 +1,5 @@
1
- import { A as APIClient, H as HttpClientConfig } from '../insights.types-BCalhgkj.js';
2
- export { p as AggregatedInsights, E as INSIGHTS_PERIODS, y as INSTAGRAM_ACCOUNT_METRICS, z as INSTAGRAM_DEMOGRAPHICS_METRICS, B as INSTAGRAM_MEDIA_METRICS_COMMON, C as INSTAGRAM_REELS_METRICS, D as INSTAGRAM_STORIES_METRICS, b as InsightBreakdown, a as InsightDataItem, I as InsightValue, q as InsightsError, F as InsightsPeriod, c as InsightsResponse, l as InstagramAccountInsightsParams, n as InstagramAccountSummary, o as InstagramMediaInsights, m as InstagramMediaInsightsParams, M as METRIC_PRESETS, r as PAGE_METRICS_LIFETIME, s as PAGE_METRICS_PERIODIC, x as PHOTO_METRICS, t as POST_METRICS, P as PageInsightsParams, d as PageOverview, k as PhotoInsights, j as PhotoInsightsParams, f as PostInsights, e as PostInsightsParams, v as REELS_METRICS, w as REELS_METRICS_EXTENDED, i as ReelsInsights, R as ReelsInsightsParams, u as VIDEO_METRICS, g as VideoInsights, V as VideoInsightsParams, h as VideoWithInsights } from '../insights.types-BCalhgkj.js';
1
+ import { A as APIClient, H as HttpClientConfig } from '../insights.types-DBDsXg7x.js';
2
+ export { a as AccountInfoResponse, s as AggregatedInsights, D as DebugTokenData, b as DebugTokenResponse, K as INSIGHTS_PERIODS, C as INSTAGRAM_ACCOUNT_METRICS, E as INSTAGRAM_DEMOGRAPHICS_METRICS, F as INSTAGRAM_MEDIA_METRICS_COMMON, G as INSTAGRAM_REELS_METRICS, J as INSTAGRAM_STORIES_METRICS, d as InsightBreakdown, c as InsightDataItem, I as InsightValue, t as InsightsError, L as InsightsPeriod, e as InsightsResponse, o as InstagramAccountInsightsParams, q as InstagramAccountSummary, r as InstagramMediaInsights, p as InstagramMediaInsightsParams, M as METRIC_PRESETS, u as PAGE_METRICS_LIFETIME, v as PAGE_METRICS_PERIODIC, B as PHOTO_METRICS, w as POST_METRICS, f as PageInsightsParams, g as PageOverview, P as PagePictureResponse, n as PhotoInsights, m as PhotoInsightsParams, i as PostInsights, h as PostInsightsParams, y as REELS_METRICS, z as REELS_METRICS_EXTENDED, l as ReelsInsights, R as ReelsInsightsParams, x as VIDEO_METRICS, j as VideoInsights, V as VideoInsightsParams, k as VideoWithInsights } from '../insights.types-DBDsXg7x.js';
3
3
  import { R as RequestOptions } from '../auth.types-Do2L11TO.js';
4
4
  export { d as APIErrorData, A as AuthProvider, b as AuthResult, L as LoginConfig, O as OAuthConfig, a as OAuthResult, c as PaginatedResponse, P as ProviderName, U as UserProfile } from '../auth.types-Do2L11TO.js';
5
5
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as APIClient, p as AggregatedInsights, H as HttpClientConfig, E as INSIGHTS_PERIODS, y as INSTAGRAM_ACCOUNT_METRICS, z as INSTAGRAM_DEMOGRAPHICS_METRICS, B as INSTAGRAM_MEDIA_METRICS_COMMON, C as INSTAGRAM_REELS_METRICS, D as INSTAGRAM_STORIES_METRICS, b as InsightBreakdown, a as InsightDataItem, I as InsightValue, q as InsightsError, F as InsightsPeriod, c as InsightsResponse, l as InstagramAccountInsightsParams, n as InstagramAccountSummary, o as InstagramMediaInsights, m as InstagramMediaInsightsParams, M as METRIC_PRESETS, r as PAGE_METRICS_LIFETIME, s as PAGE_METRICS_PERIODIC, x as PHOTO_METRICS, t as POST_METRICS, P as PageInsightsParams, d as PageOverview, k as PhotoInsights, j as PhotoInsightsParams, f as PostInsights, e as PostInsightsParams, v as REELS_METRICS, w as REELS_METRICS_EXTENDED, i as ReelsInsights, R as ReelsInsightsParams, u as VIDEO_METRICS, g as VideoInsights, V as VideoInsightsParams, h as VideoWithInsights } from './insights.types-hLzNJATM.mjs';
1
+ export { A as APIClient, a as AccountInfoResponse, s as AggregatedInsights, D as DebugTokenData, b as DebugTokenResponse, H as HttpClientConfig, K as INSIGHTS_PERIODS, C as INSTAGRAM_ACCOUNT_METRICS, E as INSTAGRAM_DEMOGRAPHICS_METRICS, F as INSTAGRAM_MEDIA_METRICS_COMMON, G as INSTAGRAM_REELS_METRICS, J as INSTAGRAM_STORIES_METRICS, d as InsightBreakdown, c as InsightDataItem, I as InsightValue, t as InsightsError, L as InsightsPeriod, e as InsightsResponse, o as InstagramAccountInsightsParams, q as InstagramAccountSummary, r as InstagramMediaInsights, p as InstagramMediaInsightsParams, M as METRIC_PRESETS, u as PAGE_METRICS_LIFETIME, v as PAGE_METRICS_PERIODIC, B as PHOTO_METRICS, w as POST_METRICS, f as PageInsightsParams, g as PageOverview, P as PagePictureResponse, n as PhotoInsights, m as PhotoInsightsParams, i as PostInsights, h as PostInsightsParams, y as REELS_METRICS, z as REELS_METRICS_EXTENDED, l as ReelsInsights, R as ReelsInsightsParams, x as VIDEO_METRICS, j as VideoInsights, V as VideoInsightsParams, k as VideoWithInsights } from './insights.types-BIXofwk0.mjs';
2
2
  export { d as APIErrorData, A as AuthProvider, b as AuthResult, L as LoginConfig, O as OAuthConfig, a as OAuthResult, c as PaginatedResponse, P as ProviderName, R as RequestOptions, U as UserProfile } from './auth.types-Do2L11TO.mjs';
3
3
  export { APIError, AuthError, BaseError, Conversation, ConversationsResponse, FACEBOOK_GRAPH_API_BASE_URL, FACEBOOK_GRAPH_API_VERSION, FACEBOOK_OAUTH_AUTHORIZATION_URL, GetConversationsOptions, GetMessagesOptions, HttpClient, Message, MessageAttachment, MessagesResponse, MessagingParticipant, PagingCursors, SendMessageResponse } from './core/index.mjs';
4
4
  export { OAuthAdapter } from './adapters/index.mjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as APIClient, p as AggregatedInsights, H as HttpClientConfig, E as INSIGHTS_PERIODS, y as INSTAGRAM_ACCOUNT_METRICS, z as INSTAGRAM_DEMOGRAPHICS_METRICS, B as INSTAGRAM_MEDIA_METRICS_COMMON, C as INSTAGRAM_REELS_METRICS, D as INSTAGRAM_STORIES_METRICS, b as InsightBreakdown, a as InsightDataItem, I as InsightValue, q as InsightsError, F as InsightsPeriod, c as InsightsResponse, l as InstagramAccountInsightsParams, n as InstagramAccountSummary, o as InstagramMediaInsights, m as InstagramMediaInsightsParams, M as METRIC_PRESETS, r as PAGE_METRICS_LIFETIME, s as PAGE_METRICS_PERIODIC, x as PHOTO_METRICS, t as POST_METRICS, P as PageInsightsParams, d as PageOverview, k as PhotoInsights, j as PhotoInsightsParams, f as PostInsights, e as PostInsightsParams, v as REELS_METRICS, w as REELS_METRICS_EXTENDED, i as ReelsInsights, R as ReelsInsightsParams, u as VIDEO_METRICS, g as VideoInsights, V as VideoInsightsParams, h as VideoWithInsights } from './insights.types-BCalhgkj.js';
1
+ export { A as APIClient, a as AccountInfoResponse, s as AggregatedInsights, D as DebugTokenData, b as DebugTokenResponse, H as HttpClientConfig, K as INSIGHTS_PERIODS, C as INSTAGRAM_ACCOUNT_METRICS, E as INSTAGRAM_DEMOGRAPHICS_METRICS, F as INSTAGRAM_MEDIA_METRICS_COMMON, G as INSTAGRAM_REELS_METRICS, J as INSTAGRAM_STORIES_METRICS, d as InsightBreakdown, c as InsightDataItem, I as InsightValue, t as InsightsError, L as InsightsPeriod, e as InsightsResponse, o as InstagramAccountInsightsParams, q as InstagramAccountSummary, r as InstagramMediaInsights, p as InstagramMediaInsightsParams, M as METRIC_PRESETS, u as PAGE_METRICS_LIFETIME, v as PAGE_METRICS_PERIODIC, B as PHOTO_METRICS, w as POST_METRICS, f as PageInsightsParams, g as PageOverview, P as PagePictureResponse, n as PhotoInsights, m as PhotoInsightsParams, i as PostInsights, h as PostInsightsParams, y as REELS_METRICS, z as REELS_METRICS_EXTENDED, l as ReelsInsights, R as ReelsInsightsParams, x as VIDEO_METRICS, j as VideoInsights, V as VideoInsightsParams, k as VideoWithInsights } from './insights.types-DBDsXg7x.js';
2
2
  export { d as APIErrorData, A as AuthProvider, b as AuthResult, L as LoginConfig, O as OAuthConfig, a as OAuthResult, c as PaginatedResponse, P as ProviderName, R as RequestOptions, U as UserProfile } from './auth.types-Do2L11TO.js';
3
3
  export { APIError, AuthError, BaseError, Conversation, ConversationsResponse, FACEBOOK_GRAPH_API_BASE_URL, FACEBOOK_GRAPH_API_VERSION, FACEBOOK_OAUTH_AUTHORIZATION_URL, GetConversationsOptions, GetMessagesOptions, HttpClient, Message, MessageAttachment, MessagesResponse, MessagingParticipant, PagingCursors, SendMessageResponse } from './core/index.js';
4
4
  export { OAuthAdapter } from './adapters/index.js';
package/dist/index.js CHANGED
@@ -469,15 +469,17 @@ var FacebookAPI = class {
469
469
  * Uses Facebook's debug_token endpoint
470
470
  *
471
471
  * @param inputToken - The token to validate
472
- * @param appAccessToken - App token (app_id|app_secret)
473
- * @returns Token debug information
472
+ * @param appAccessToken - App token or access token for authentication (uses inputToken if not provided)
473
+ * @returns Token debug information including scopes and validity
474
474
  */
475
475
  async debugToken(inputToken, appAccessToken) {
476
476
  try {
477
- return await this.get("/debug_token", {
477
+ const token = appAccessToken || inputToken;
478
+ const response = await this.get("/debug_token", {
478
479
  input_token: inputToken,
479
- access_token: appAccessToken
480
+ access_token: token
480
481
  });
482
+ return response.data;
481
483
  } catch (error) {
482
484
  throw new APIError(
483
485
  `Failed to debug token: ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -1056,6 +1058,67 @@ var FacebookAPI = class {
1056
1058
  );
1057
1059
  }
1058
1060
  }
1061
+ // ============= Account & Token Methods =============
1062
+ /**
1063
+ * Get account info from the /me endpoint
1064
+ * Returns different data depending on token type (user vs page)
1065
+ *
1066
+ * @param accessToken - Optional access token (uses instance token if not provided)
1067
+ * @returns Account info with id and name
1068
+ */
1069
+ async getAccountInfo(accessToken) {
1070
+ try {
1071
+ const token = accessToken || this.accessToken;
1072
+ if (!token) {
1073
+ throw new APIError("Access token is required", 401, "NO_TOKEN");
1074
+ }
1075
+ const response = await this.get("/me", {
1076
+ access_token: token
1077
+ });
1078
+ return response;
1079
+ } catch (error) {
1080
+ throw new APIError(
1081
+ `Failed to get account info: ${error instanceof Error ? error.message : "Unknown error"}`,
1082
+ void 0,
1083
+ "ACCOUNT_INFO_ERROR",
1084
+ error
1085
+ );
1086
+ }
1087
+ }
1088
+ /**
1089
+ * Get the profile picture URL for a Facebook Page
1090
+ *
1091
+ * @param pageId - The Facebook Page ID
1092
+ * @param type - Picture size: 'small', 'normal', 'large', 'square' (default: 'large')
1093
+ * @returns The picture URL
1094
+ */
1095
+ async getPagePictureUrl(pageId, type = "large") {
1096
+ try {
1097
+ const response = await this.get(`/${pageId}/picture`, {
1098
+ type,
1099
+ redirect: "false"
1100
+ });
1101
+ return response.data.url;
1102
+ } catch (error) {
1103
+ throw new APIError(
1104
+ `Failed to get page picture: ${error instanceof Error ? error.message : "Unknown error"}`,
1105
+ void 0,
1106
+ "PAGE_PICTURE_ERROR",
1107
+ error
1108
+ );
1109
+ }
1110
+ }
1111
+ /**
1112
+ * Build a static URL for page picture (no API call needed)
1113
+ * Useful when you just need the URL without fetching metadata
1114
+ *
1115
+ * @param pageId - The Facebook Page ID
1116
+ * @param type - Picture size: 'small', 'normal', 'large', 'square' (default: 'large')
1117
+ * @returns Static picture URL that redirects to the actual image
1118
+ */
1119
+ static buildPagePictureUrl(pageId, type = "large") {
1120
+ return `${FACEBOOK_GRAPH_API_BASE_URL}/${pageId}/picture?type=${type}`;
1121
+ }
1059
1122
  };
1060
1123
 
1061
1124
  // providers/facebook/auth/FacebookAuth.ts
@@ -1153,14 +1216,19 @@ var FacebookAuth = class {
1153
1216
  * Get authorization URL
1154
1217
  */
1155
1218
  getAuthorizationUrl(scopes, redirectUri, state) {
1219
+ if (!this.config.appId) {
1220
+ throw new AuthError("appId is required for authorization", "MISSING_APP_ID");
1221
+ }
1156
1222
  const params = new URLSearchParams({
1157
1223
  client_id: this.config.appId,
1158
1224
  redirect_uri: redirectUri,
1159
1225
  scope: scopes.join(","),
1160
1226
  response_type: "token",
1161
- display: "popup",
1162
- ...state && { state }
1227
+ display: "popup"
1163
1228
  });
1229
+ if (state) {
1230
+ params.set("state", state);
1231
+ }
1164
1232
  return `${FACEBOOK_OAUTH_AUTHORIZATION_URL}?${params.toString()}`;
1165
1233
  }
1166
1234
  /**
@@ -1215,11 +1283,11 @@ var FacebookScopesBusiness = /* @__PURE__ */ ((FacebookScopesBusiness2) => {
1215
1283
  FacebookScopesBusiness2["COMMERCE_ACCOUNT_READ_REPORTS"] = "commerce_account_read_reports";
1216
1284
  FacebookScopesBusiness2["COMMERCE_ACCOUNT_READ_SETTINGS"] = "commerce_account_read_settings";
1217
1285
  FacebookScopesBusiness2["COMMERCE_MANAGE_ACCOUNTS"] = "commerce_manage_accounts";
1218
- FacebookScopesBusiness2["INSTAGRAM_BASIC"] = "instagram_business_basic";
1219
- FacebookScopesBusiness2["INSTAGRAM_CONTENT_PUBLISH"] = "instagram_business_content_publish";
1220
- FacebookScopesBusiness2["INSTAGRAM_MANAGE_COMMENTS"] = "instagram_business_manage_comments";
1221
- FacebookScopesBusiness2["INSTAGRAM_MANAGE_INSIGHTS"] = "instagram_business_manage_insights";
1222
- FacebookScopesBusiness2["INSTAGRAM_MANAGE_MESSAGES"] = "instagram_business_manage_messages";
1286
+ FacebookScopesBusiness2["INSTAGRAM_BASIC"] = "instagram_basic";
1287
+ FacebookScopesBusiness2["INSTAGRAM_CONTENT_PUBLISH"] = "instagram_content_publish";
1288
+ FacebookScopesBusiness2["INSTAGRAM_MANAGE_COMMENTS"] = "instagram_manage_comments";
1289
+ FacebookScopesBusiness2["INSTAGRAM_MANAGE_INSIGHTS"] = "instagram_manage_insights";
1290
+ FacebookScopesBusiness2["INSTAGRAM_MANAGE_MESSAGES"] = "instagram_manage_messages";
1223
1291
  FacebookScopesBusiness2["INSTAGRAM_SHOPPING_TAG_PRODUCTS"] = "instagram_shopping_tag_products";
1224
1292
  FacebookScopesBusiness2["LEADS_RETRIEVAL"] = "leads_retrieval";
1225
1293
  FacebookScopesBusiness2["MANAGE_APP_SOLUTIONS"] = "manage_app_solutions";
@@ -1985,6 +2053,33 @@ var InstagramAPI = class {
1985
2053
  );
1986
2054
  }
1987
2055
  }
2056
+ // ============= Account Methods =============
2057
+ /**
2058
+ * Get account info from the /me endpoint
2059
+ * Returns the account associated with the current access token
2060
+ *
2061
+ * @param accessToken - Optional access token (uses instance token if not provided)
2062
+ * @returns Account info with id and name
2063
+ */
2064
+ async getAccountInfo(accessToken) {
2065
+ try {
2066
+ const token = accessToken || this.accessToken;
2067
+ if (!token) {
2068
+ throw new APIError("Access token is required", 401, "NO_TOKEN");
2069
+ }
2070
+ const response = await this.get("/me", {
2071
+ access_token: token
2072
+ });
2073
+ return response;
2074
+ } catch (error) {
2075
+ throw new APIError(
2076
+ `Failed to get account info: ${error instanceof Error ? error.message : "Unknown error"}`,
2077
+ void 0,
2078
+ "ACCOUNT_INFO_ERROR",
2079
+ error
2080
+ );
2081
+ }
2082
+ }
1988
2083
  };
1989
2084
 
1990
2085
  // providers/instagram/InstagramProvider.ts