Comparing version 2.0.1 to 2.0.2
@@ -1,6 +0,6 @@ | ||
import { CRUDNodeInfo, CRUDEdgeInfoSet } from './node'; | ||
import { AdAccount, AdNetworkAnalyticsAsyncQueryResult, Album, Application, ApplicationAppEventTypes, ApplicationPermission, ApplicationPermissionStatus, AppRequest, AsyncSession, Business, ButtonAutoDetectionDeviceSelection, CanvasAppAsset, Comment, CommerceMerchantSettings, ConversionConfig, CPASAdvertiserPartnershipRecommendation, CPASCollaborationRequest, CTCertDomain, DACheck, GamesIAPProduct, InsightsQueryResult, MobileSDKGK, Photo, ProductCatalog, Profile, ProfilePictureSource, Reaction, CommerceReturn, Role, SDKMLModel, TestAccount, Conversation, Message, Destination, Doc, Event, Flight, FriendList, GroupDoc, GroupMessage, ImageCopyright, LeadGenData, UserLeadGenInfo, Link, LiveVideo, LiveVideoInputStream, LiveEncoder, User, Page, LiveVideoError, VideoPoll, MailingAddress, GroupFile, MediaFingerprint, NativeOffer, NativeOfferView, OfflineConversionDataSet, OfflineConversionDataSetUpload, CustomAudience, CustomConversion, OfflineConversionDataSetStats, CommerceMerchantTaxSettings, Video, Post, SignalsUploadProgress, GamesIAPOrder, PagePost, AssignedUser, AudioCopyright, CommerceMerchantSettingsSetupStatus, CommerceOrder, CommerceOrderTransactionDetail, CommercePayout, InsightsResult, InstagramUser, InstantArticle, InstantArticleInsightsQueryResult, MessagingFeatureReview, PageCallToAction, PageSettings, PageThreadOwner, PageUserMessageThreadLabel, Persona, Recommendation, RTBDynamicPost, Tab, VideoCopyright, VideoCopyrightRule, VideoList, EventTour, Group, InsightBreakdown, BusinessUser, BusinessAssetGroup, Permission, URL, UserIDForApp, AdStudy, PaymentEnginePayment, PaymentSubscription, UserIDForPage, AppRequestFormerRecipient } from '../graph-api/types'; | ||
import { CustomUserSettings } from '../messenger-platform/apis/custom-user-settings'; | ||
import { MessengerProfile } from '../messenger-platform/apis/messenger-profile'; | ||
import { PageMessageRequest } from '../messenger-platform/apis/send'; | ||
import type { CRUDNodeInfo, CRUDEdgeInfoSet } from './node'; | ||
import type { AdAccount, AdNetworkAnalyticsAsyncQueryResult, Album, Application, ApplicationAppEventTypes, ApplicationPermission, ApplicationPermissionStatus, AppRequest, AsyncSession, Business, ButtonAutoDetectionDeviceSelection, CanvasAppAsset, Comment, CommerceMerchantSettings, ConversionConfig, CPASAdvertiserPartnershipRecommendation, CPASCollaborationRequest, CTCertDomain, DACheck, GamesIAPProduct, InsightsQueryResult, MobileSDKGK, Photo, ProductCatalog, Profile, ProfilePictureSource, Reaction, CommerceReturn, Role, SDKMLModel, TestAccount, Conversation, Message, Destination, Doc, Event, Flight, FriendList, GroupDoc, GroupMessage, ImageCopyright, LeadGenData, UserLeadGenInfo, Link, LiveVideo, LiveVideoInputStream, LiveEncoder, User, Page, LiveVideoError, VideoPoll, MailingAddress, GroupFile, MediaFingerprint, NativeOffer, NativeOfferView, OfflineConversionDataSet, OfflineConversionDataSetUpload, CustomAudience, CustomConversion, OfflineConversionDataSetStats, CommerceMerchantTaxSettings, Video, Post, SignalsUploadProgress, GamesIAPOrder, PagePost, AssignedUser, AudioCopyright, CommerceMerchantSettingsSetupStatus, CommerceOrder, CommerceOrderTransactionDetail, CommercePayout, InsightsResult, InstagramUser, InstantArticle, InstantArticleInsightsQueryResult, MessagingFeatureReview, PageCallToAction, PageSettings, PageThreadOwner, PageUserMessageThreadLabel, Persona, Recommendation, RTBDynamicPost, Tab, VideoCopyright, VideoCopyrightRule, VideoList, EventTour, Group, InsightBreakdown, BusinessUser, BusinessAssetGroup, Permission, URL, UserIDForApp, AdStudy, PaymentEnginePayment, PaymentSubscription, UserIDForPage, AppRequestFormerRecipient } from '../graph-api/types'; | ||
import type { CustomUserSettings } from '../messenger-platform/apis/custom-user-settings'; | ||
import type { MessengerProfile } from '../messenger-platform/apis/messenger-profile'; | ||
import type { PageMessageRequest } from '../messenger-platform/apis/send'; | ||
interface NodeGetterTypeParams { | ||
@@ -7,0 +7,0 @@ node: CRUDNodeInfo; |
@@ -1,4 +0,4 @@ | ||
import { FacebookAppBase } from '../index'; | ||
import { DePromise, DeepPartial } from '../util'; | ||
import { APISpec } from '.'; | ||
import type { FacebookAppBase } from '../index'; | ||
import type { DePromise, DeepPartial } from '../util'; | ||
import type { APISpec } from '.'; | ||
export declare type NodeGetter<ThisNode extends CRUDNodeInfo, Edges extends CRUDEdgeInfoSet> = (id?: string) => Node<ThisNode, Edges>; | ||
@@ -44,6 +44,6 @@ export interface CRUDNodeInfo { | ||
private id?; | ||
constructor(GraphAPI: FacebookAppBase<APISpec>['GraphAPI'], id?: string); | ||
constructor(GraphAPI: FacebookAppBase<APISpec>['GraphAPI'], id?: string | undefined); | ||
Edge<T extends keyof Edges>(edge: T): Edge<Edges[T]>; | ||
read: <FieldsTuple extends Exclude<keyof ThisNode["read_return"], "id">[]>(access_token: string, fields?: FieldsTuple, params?: Partial<ThisNode['read_params']>) => Promise<Pick<GraphAPIResponse<ThisNode["read_return"]>, "id" | FieldsTuple[number]>>; | ||
delete: (access_token: string, params?: Partial<ThisNode['delete_params']>) => Promise<ThisNode["delete_return"]>; | ||
read: <FieldsTuple extends Exclude<keyof ThisNode["read_return"], "id">[]>(access_token: string, fields?: FieldsTuple | undefined, params?: Partial<ThisNode["read_params"]> | undefined) => Promise<Pick<GraphAPIResponse<ThisNode["read_return"]>, "id" | FieldsTuple[number]>>; | ||
delete: (access_token: string, params?: Partial<ThisNode["delete_params"]> | undefined) => Promise<ThisNode["delete_return"]>; | ||
} | ||
@@ -53,6 +53,6 @@ export declare class Edge<ThisEdge extends CRUDEdgeInfo> implements CRUDEdge<ThisEdge> { | ||
private GraphAPI; | ||
private id?; | ||
constructor(edge: ThisEdge['edge'], GraphAPI: FacebookAppBase<APISpec>['GraphAPI'], id?: string); | ||
read: <FieldsTuple extends Exclude<keyof ThisEdge["read_return"], "id">[]>(access_token: string, fields?: FieldsTuple, params?: DeepPartial<ThisEdge['read_params']>) => Promise<EdgeResponse<Pick<GraphAPIResponse<ThisEdge["read_return"]>, "id" | FieldsTuple[number]>>>; | ||
create: (access_token: string, data: Partial<ThisEdge['create_type']>, params?: Partial<ThisEdge['create_params']>) => Promise<ThisEdge["create_return"]>; | ||
private id; | ||
constructor(edge: ThisEdge['edge'], GraphAPI: FacebookAppBase<APISpec>['GraphAPI'], id: string); | ||
read: <FieldsTuple extends Exclude<keyof ThisEdge["read_return"], "id">[]>(access_token: string, fields?: FieldsTuple | undefined, params?: DeepPartial<ThisEdge["read_params"]> | undefined) => Promise<EdgeResponse<Pick<GraphAPIResponse<ThisEdge["read_return"]>, "id" | FieldsTuple[number]>>>; | ||
create: (access_token: string, data: Partial<ThisEdge['create_type']>, params?: Partial<ThisEdge["create_params"]> | undefined) => Promise<ThisEdge["create_return"]>; | ||
} | ||
@@ -59,0 +59,0 @@ interface EdgeResponse<NodeType> { |
@@ -18,2 +18,4 @@ "use strict"; | ||
this.read = (access_token, fields, params) => __awaiter(this, void 0, void 0, function* () { | ||
if (!this.id) | ||
throw new Error('Cannot read node with unspecified id'); | ||
return yield this.GraphAPI.get(this.id, Object.assign(Object.assign(params !== null && params !== void 0 ? params : {}, { access_token }), { | ||
@@ -24,2 +26,4 @@ fields: fields === null || fields === void 0 ? void 0 : fields.toString(), | ||
this.delete = (access_token, params) => __awaiter(this, void 0, void 0, function* () { | ||
if (!this.id) | ||
throw new Error('Cannot delete node with unspecified id'); | ||
return yield this.GraphAPI.delete(this.id, Object.assign(params !== null && params !== void 0 ? params : {}, { access_token })); | ||
@@ -29,3 +33,5 @@ }); | ||
Edge(edge) { | ||
return new Edge(edge, this.GraphAPI); | ||
if (!this.id) | ||
throw new Error('Cannot access edges of node with unspecified id'); | ||
return new Edge(edge, this.GraphAPI, this.id); | ||
} | ||
@@ -32,0 +38,0 @@ } |
import { AxiosInstance } from 'axios'; | ||
import { APISpec, APIv9 } from './api-spec'; | ||
import type { APISpec, APIv9 } from './api-spec'; | ||
import Node from './api-spec/node'; | ||
import { KnownKeys } from './util'; | ||
import type { KnownKeys } from './util'; | ||
interface FacebookAppConfig { | ||
@@ -15,9 +15,9 @@ readonly appId: string; | ||
protected GraphAPI: { | ||
get: <ReturnType_1, ParamsType = any>(endpoint: string, _params?: ParamsType & { | ||
get: <ReturnType_1, ParamsType = any>(endpoint: string, _params: ParamsType & { | ||
access_token: string; | ||
}) => Promise<ReturnType_1>; | ||
post: <ReturnType_2, DataType = any, ParamsType_1 = any>(endpoint: string, data: DataType, _params?: ParamsType_1 & { | ||
post: <ReturnType_2, DataType = any, ParamsType_1 = any>(endpoint: string, data: DataType, _params: ParamsType_1 & { | ||
access_token: string; | ||
}) => Promise<ReturnType_2>; | ||
delete: <ReturnType_3, ParamsType_2 = any>(endpoint: string, _params?: ParamsType_2 & { | ||
delete: <ReturnType_3, ParamsType_2 = any>(endpoint: string, _params: ParamsType_2 & { | ||
access_token: string; | ||
@@ -32,4 +32,4 @@ }) => Promise<ReturnType_3>; | ||
export declare class FacebookApp extends FacebookAppNoExposedNodes { | ||
Node: <NodeType extends never>(node: NodeType, id?: string) => Node<APIv9[NodeType]["node"], APIv9[NodeType]["edges"]>; | ||
Node: <NodeType extends "Album" | "AppRequest" | "Application" | "AsyncSession" | "CPASAdvertiserPartnershipRecommendation" | "CPASCollaborationRequest" | "CTCertDomain" | "Comment" | "CommerceMerchantSettings" | "Conversation" | "Destination" | "Doc" | "Event" | "Flight" | "FriendList" | "Group" | "GroupDoc" | "GroupMessage" | "ImageCopyright" | "LeadGenData" | "Link" | "LiveEncoder" | "LiveVideo" | "LiveVideoInputStream" | "MailingAddress" | "MediaFingerprint" | "NativeOffer" | "OfflineConversionDataSet" | "OfflineConversionDataSetUpload" | "Page" | "PageCallToAction" | "PagePost" | "Photo" | "User" | "Video" | "VideoList" | "VideoPoll">(node: NodeType, id?: string | undefined) => Node<APIv9[NodeType]["node"], APIv9[NodeType]["edges"]>; | ||
} | ||
export { APISpec }; | ||
export type { APISpec }; |
@@ -19,3 +19,5 @@ "use strict"; | ||
const crypto_1 = __importDefault(require("crypto")); | ||
const handleFacebookError = (e) => { | ||
const getFacebookError = (e) => { | ||
if (!e.response) | ||
return new Error('Unexpected error'); | ||
const { status, data } = e.response; | ||
@@ -27,6 +29,6 @@ if (status.toString()[0] === '4') { | ||
fbError.name = _fbError.type; | ||
throw fbError; | ||
return fbError; | ||
} | ||
else | ||
throw new Error('Unexpected error'); | ||
return new Error('Unexpected error'); | ||
}; | ||
@@ -52,3 +54,3 @@ class FacebookAppBase { | ||
catch (e) { | ||
handleFacebookError(e); | ||
throw getFacebookError(e); | ||
} | ||
@@ -67,3 +69,3 @@ }), | ||
catch (e) { | ||
handleFacebookError(e); | ||
throw getFacebookError(e); | ||
} | ||
@@ -82,3 +84,3 @@ }), | ||
catch (e) { | ||
handleFacebookError(e); | ||
throw getFacebookError(e); | ||
} | ||
@@ -85,0 +87,0 @@ }), |
@@ -1,2 +0,2 @@ | ||
import { MessengerProfilePersistentMenu } from './messenger-profile'; | ||
import type { MessengerProfilePersistentMenu } from './messenger-profile'; | ||
export interface CustomUserSettings { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import { XOR } from '../../util'; | ||
import { PostbackButton, URLButton } from './send'; | ||
import type { XOR } from '../../util'; | ||
import type { PostbackButton, URLButton } from './send'; | ||
export interface MessengerProfile { | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { XOR } from '../../util'; | ||
import type { XOR } from '../../util'; | ||
export interface PageMessageRequest { | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import { XOR } from '../../util'; | ||
import { MessageTemplate } from '../apis/send'; | ||
import type { XOR } from '../../util'; | ||
import type { MessageTemplate } from '../apis/send'; | ||
export interface MessageReceivedEvent { | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,4 +0,4 @@ | ||
import { WebhookEventNotificationBase } from '../../graph-api/webhooks'; | ||
import { XOR } from '../../util'; | ||
import { AccountLinkingEvent, HandoverProtocolAppRolesEvent, HandoverProtocolPassThreadControlEvent, HandoverProtocolRequestThreadControlEvent, HandoverProtocolStandbyChannelEvent, HandoverProtocolTakeThreadControlEvent, InstantGameEvent, MessageDeliveredEvent, MessageEchoEvent, MessageReactionEvent, MessageReadEvent, MessageReceivedEvent, PluginOptInEvent, PolicyEnforcementEvent, PostbackRecievedEvent, ReferralEvent } from './events'; | ||
import type { WebhookEventNotificationBase } from '../../graph-api/webhooks'; | ||
import type { XOR } from '../../util'; | ||
import type { AccountLinkingEvent, HandoverProtocolAppRolesEvent, HandoverProtocolPassThreadControlEvent, HandoverProtocolRequestThreadControlEvent, HandoverProtocolStandbyChannelEvent, HandoverProtocolTakeThreadControlEvent, InstantGameEvent, MessageDeliveredEvent, MessageEchoEvent, MessageReactionEvent, MessageReadEvent, MessageReceivedEvent, PluginOptInEvent, PolicyEnforcementEvent, PostbackRecievedEvent, ReferralEvent } from './events'; | ||
interface MessengerWebhookEventNotificationEntry { | ||
@@ -5,0 +5,0 @@ /** |
{ | ||
"name": "fbsdk-ts", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Strongly-typed promise-based client library for Facebook's Graph API using TypeScript", | ||
@@ -9,3 +9,3 @@ "main": "dist/index.js", | ||
"build": "tsc", | ||
"prune": "node bin/prune.js", | ||
"prune": "ts-node bin/prune.ts", | ||
"all": "npm run clean && npm run build && npm run prune" | ||
@@ -29,3 +29,4 @@ }, | ||
"@types/node": "^14.14.21", | ||
"typescript": "^4.1.3" | ||
"ts-node": "^10.2.1", | ||
"typescript": "^4.4.3" | ||
}, | ||
@@ -32,0 +33,0 @@ "repository": "github:nmggithub/fbsdk-ts", |
@@ -312,3 +312,3 @@ # fbsdk-ts | ||
class CustomFacebookApp extends FacebookAppBase<CustomAPISpec> { | ||
graphAPIAxiosInstance = axios.create({ | ||
protected graphAPIAxiosInstance = axios.create({ | ||
baseURL: `{CUSTOM-GRAPH-API-BASE-URL}`, | ||
@@ -315,0 +315,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
374319
11903
3