Skip to content
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
ServerEvent,
UserData,
IGUser,
InstagramInsightsResult
InstagramInsightsResult,
AppData,
ExtendedDeviceInfo
} from 'facebook-nodejs-business-sdk';
import { FacebookRequestError } from 'facebook-nodejs-business-sdk/src/exceptions';
import TEventRequest from "facebook-nodejs-business-sdk/src/objects/serverside/event-request";
Expand All @@ -18,8 +20,8 @@ async function testGetAdsFetchFirstPageFalse(): Promise<Array<Record<string, str
const fbAdsApi = new FacebookAdsApi('TOKEN');
fbAdsApi.setDebug(true);

const fbAdAccount = new AdAccount(`act_ID`, undefined, undefined, fbAdsApi);
const cursor = fbAdAccount.getAds(['id', 'name'], { limit: 10 }, false);
const fbAdAccount = new AdAccount(`act_ID`, {}, undefined, fbAdsApi);
const cursor = await fbAdAccount.getAds(['id', 'name'], { limit: 10 }, false);

while (cursor.hasNext()) {
await cursor.next();
Expand All @@ -41,7 +43,7 @@ async function testGetAdsFetchFirstPageDefault(): Promise<Array<Record<string, s
const fbAdsApi = new FacebookAdsApi('TOKEN');
fbAdsApi.setDebug(true);

const fbAdAccount = new AdAccount(`act_ID`, undefined, undefined, fbAdsApi);
const fbAdAccount = new AdAccount(`act_ID`, {}, undefined, fbAdsApi);
const cursor = await fbAdAccount.getAds(['id', 'name'], { limit: 10 });

while (true) {
Expand All @@ -68,7 +70,7 @@ async function testGetAdsFetchFirstPageBoolean(): Promise<Array<Record<string, s
const fbAdsApi = new FacebookAdsApi('TOKEN');
fbAdsApi.setDebug(true);

const fbAdAccount = new AdAccount(`act_ID`, undefined, undefined, fbAdsApi);
const fbAdAccount = new AdAccount(`act_ID`, {}, undefined, fbAdsApi);
const fetchFirstPage = Math.random() > 0.5;
const cursorOrPromise = fbAdAccount.getAds(['id', 'name'], { limit: 10 }, fetchFirstPage);
const cursor = cursorOrPromise instanceof Promise ? await cursorOrPromise : cursorOrPromise;
Expand Down Expand Up @@ -97,21 +99,22 @@ async function testGetAdsFetchFirstPageBoolean(): Promise<Array<Record<string, s

async function checkType() {
const fbAdsApi: FacebookAdsApi = new FacebookAdsApi('TOKEN');
const fbAdAccount: AdAccount = new AdAccount(`act_ID`, undefined, undefined, fbAdsApi);
const fbAdAccount: AdAccount = new AdAccount(`act_ID`, {}, undefined, fbAdsApi);
}

async function testConversionEvent(): Promise<TEventRequest> {
const userData = (new UserData())
const userData = (new UserData('[email protected]','','','','','','','','','','','','','','','','','','','','','','','','',''))
.setEmails(['[email protected]'])
.setPhones(['12345678901', '14251234567']);

const content = (new Content())
.setId('product123');
const content = new Content('product123',5,2,'','','','','');

const customData = (new CustomData())
const customData = (new CustomData(2,'','','',[],[],'','',0,0,'','','','',{}))
.setContents([content]);
const extendedDeviceInfo = new ExtendedDeviceInfo('','','','','','','','','',0,0,'',0,0,0,'');
const appData = new AppData(false, false, '',false, extendedDeviceInfo, false, false, '', '', '', '', '');

const serverEvent = (new ServerEvent())
const serverEvent = (new ServerEvent('',0,'',userData,customData,appData,'',false,'',[],0,0,'',false,''))
.setEventName('Purchase')
.setEventTime(123)
.setUserData(userData)
Expand Down
1,457 changes: 953 additions & 504 deletions types/facebook-nodejs-business-sdk/index.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion types/facebook-nodejs-business-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/facebook-nodejs-business-sdk",
"version": "18.0.9999",
"version": "20.0.9999",
"projects": [
"https://github.com/facebook/facebook-nodejs-business-sdk"
],
Expand Down
2 changes: 1 addition & 1 deletion types/facebook-nodejs-business-sdk/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"devDependencies": {
"@khanacademy/flow-to-ts": "^0.5.2",
"facebook-nodejs-business-sdk": "^15.0.0",
"facebook-nodejs-business-sdk": "^20.0.0",
"typescript": "^4.8.4"
}
}
32 changes: 16 additions & 16 deletions types/facebook-nodejs-business-sdk/src/abstract-crud-object.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import FacebookAdsApi from './api';
import AbstractObject from './abstract-object';
import Cursor from './cursor';
import FacebookAdsApi from "./api";
import AbstractObject from "./abstract-object";
import Cursor from "./cursor";
export class AbstractCrudObject extends AbstractObject {
_parentId: string | null | undefined;
_changes: Record<any, any>;
_changes: Record<string, any>;
_api: FacebookAdsApi;
id: string;
/**
* @param {Object} data
* @param {String} parentId
* @param {FacebookAdApi} [api]
*/
constructor(id?: number | string | null, data?: Record<any, any>, parentId?: string | null, api?: FacebookAdsApi | null);
constructor(id: number | (string | null | undefined), data: Record<string, any>, parentId: string | null | undefined, api: FacebookAdsApi | null | undefined);
/**
* Define data getter and setter recording changes
* @param {String} field
Expand All @@ -22,22 +22,22 @@ export class AbstractCrudObject extends AbstractObject {
* @param {Object} data
* @return this
*/
setData(data: Record<any, any>): AbstractCrudObject;
setData(data: Record<string, any>): AbstractCrudObject;
/**
* Export changed object data
* @return {Object}
*/
exportData(): Record<any, any>;
exportData(): Record<string, any>;
/**
* Export object data
* @return {Object}
*/
exportAllData(): Record<any, any>;
exportAllData(): Record<string, any>;
/**
* Clear change history
* @return this
*/
clearHistory(): Record<any, any>;
clearHistory(): Record<string, any>;
/**
* @throws {Error} if object has no id
* @return {String}
Expand All @@ -64,19 +64,19 @@ export class AbstractCrudObject extends AbstractObject {
* @param {Object} [params]
* @return {Promise}
*/
read(fields: string[], params?: Record<any, any>): Promise<any>;
read(fields: string[], params?: Record<string, any>): Promise<any>;
/**
* Update object
* @param {Object} [params]
* @return {Promise}
*/
update(params?: Record<any, any>): Promise<any>;
update(params?: Record<string, any>): Promise<any>;
/**
* Delete object
* @param {Object} [params]
* @return {Promise}
*/
delete(params?: Record<any, any>): Promise<any>;
delete(params?: Record<string, any>): Promise<any>;
/**
* Initialize Cursor to paginate on edges
* @param {Object} targetClass
Expand All @@ -86,7 +86,7 @@ export class AbstractCrudObject extends AbstractObject {
* @param {String} [endpoint]
* @return {Cursor}
*/
getEdge(targetClass: Record<any, any>, fields: string[], params?: Record<any, any>, fetchFirstPage?: boolean, endpoint?: string | null): Cursor | Promise<any>;
getEdge(targetClass: Record<string, any>, fields: string[], params: Record<string, any>, fetchFirstPage: boolean, endpoint: string | null | undefined): Cursor | Promise<Cursor>;
/**
* Create edge object
* @param {String} [endpoint]
Expand All @@ -95,14 +95,14 @@ export class AbstractCrudObject extends AbstractObject {
* @param {Function} [targetClassConstructor]
* @return {Promise}
*/
createEdge(endpoint: string, fields: string[], params?: Record<any, any>, targetClassConstructor?: any, pathOverride?: string | null): Promise<any>;
createEdge(endpoint: string, fields: string[], params?: Record<string, any>, targetClassConstructor?: (...args: any[]) => any, pathOverride?: string | null): Promise<any>;
/**
* Delete edge object
* @param {String} [endpoint]
* @param {Object} [params]
* @return {Promise}
*/
deleteEdge(endpoint: string, params?: Record<any, any>): Promise<any>;
deleteEdge(endpoint: string, params?: Record<string, any>): Promise<any>;
/**
* Read Objects by Ids
* @param {Array} ids
Expand All @@ -111,6 +111,6 @@ export class AbstractCrudObject extends AbstractObject {
* @param {FacebookAdsApi} [api]
* @return {Promise}
*/
static getByIds(ids: number[], fields: string[], params: Record<any, any> | null | undefined, api: FacebookAdsApi): Promise<any>;
static getByIds(ids: number[], fields: string[], params: Record<string, any>, api: FacebookAdsApi): Promise<any>;
}
export default AbstractCrudObject;
6 changes: 3 additions & 3 deletions types/facebook-nodejs-business-sdk/src/abstract-object.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default class AbstractObject {
_fields: string[];
$key: string;
$value: unknown;
static get Fields(): Record<any, any>;
static get Fields(): {};
constructor();
/**
* Define data getter and setter field
Expand All @@ -22,10 +22,10 @@ export default class AbstractObject {
* @param {Object} data
* @return this
*/
setData(data: Record<any, any>): AbstractObject;
setData(data: Record<string, any>): AbstractObject;
/**
* Export object data
* @return {Object}
*/
exportData(): Record<any, any>;
exportData(): Record<string, any>;
}
18 changes: 9 additions & 9 deletions types/facebook-nodejs-business-sdk/src/api-batch.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import FacebookAdsApi from './api';
import APIRequest from './api-request';
import FacebookAdsApi from "./api";
import APIRequest from "./api-request";
/**
* Facebook Ads API Batch
*/
declare class FacebookAdsApiBatch {
_api: FacebookAdsApi;
_files: Array<Record<any, any>>;
_batch: Array<Record<any, any>>;
_successCallbacks: any[];
_failureCallbacks: any[];
_files: Array<Record<string, any>>;
_batch: Array<Record<string, any>>;
_successCallbacks: Array<(...args: any[]) => any>;
_failureCallbacks: Array<(...args: any[]) => any>;
_requests: APIRequest[];
/**
* @param {FacebookAdsApi} api
* @param {Function} successCallback
* @param {Function} failureCallback
*/
constructor(api: FacebookAdsApi, successCallback?: any, failureCallback?: any);
constructor(api: FacebookAdsApi, successCallback?: (...args: any[]) => any, failureCallback?: (...args: any[]) => any);
/**
* Adds a call to the batch.
* @param {string} method The HTTP method name (e.g. 'GET').
Expand All @@ -35,7 +35,7 @@ declare class FacebookAdsApiBatch {
* @param {APIRequest} [request] The APIRequest object
* @return {Object} An object describing the call
*/
add(method: string, relativePath: string[] | string, params?: Record<any, any>, files?: Record<any, any>, successCallback?: any, failureCallback?: any, request?: APIRequest): {
add(method: string, relativePath: string[] | string, params?: Record<string, any>, files?: Record<string, any>, successCallback?: (...args: any[]) => any, failureCallback?: (...args: any[]) => any, request?: APIRequest): {
attachedFiles: undefined | string;
body: undefined | string;
method: string;
Expand All @@ -51,7 +51,7 @@ declare class FacebookAdsApiBatch {
* will be called with the FacebookResponse of this call if the call failed.
* @return {Object} An object describing the call
*/
addRequest(request: APIRequest, successCallback?: any, failureCallback?: any): {
addRequest(request: APIRequest, successCallback?: (...args: any[]) => any, failureCallback?: (...args: any[]) => any): {
attachedFiles: undefined | string;
body: undefined | string;
method: string;
Expand Down
14 changes: 7 additions & 7 deletions types/facebook-nodejs-business-sdk/src/api-request.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ declare class APIRequest {
_endpoint: string;
_path: string[];
_fields: string[];
_params: Record<any, any>;
_fileParams: Record<any, any>;
_params: Record<string, any>;
_fileParams: Record<string, any>;
_fileCounter: number;
/**
* @param {string} nodeId The node id to perform the api call.
Expand All @@ -33,24 +33,24 @@ declare class APIRequest {
get endpoint(): string;
/**
* Getter function for path tokens
* @return {string[]} Array of path tokens
* @return {Array<string>} Array of path tokens
*/
get path(): string[];
/**
* Getter function for requested fields
* @return {string[]} Array of request fields
* @return {Array<string>} Array of request fields
*/
get fields(): string[];
/**
* Getter function for API params
* @return {Object} Object containing API Params
*/
get params(): Record<any, any>;
get params(): Record<string, any>;
/**
* Getter function for API fileparams
* @return {Object} Object containing API fileParams
*/
get fileParams(): Record<any, any>;
get fileParams(): Record<string, any>;
/**
* @param {string} filePath Path to file attached to the request
* @return {APIReqeust} APIRequest instance
Expand Down Expand Up @@ -81,6 +81,6 @@ declare class APIRequest {
* @param {Object} params An object containing param keys and values
* @return {APIRequest} APIRequest instance
*/
addParams(params: Record<any, any>): APIRequest;
addParams(params: Record<string, any>): APIRequest;
}
export default APIRequest;
10 changes: 5 additions & 5 deletions types/facebook-nodejs-business-sdk/src/api-response.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* Encapsulates an http response from Facebook's Graph API.
*/
declare class APIResponse {
_body: Record<any, any>;
_body: Record<string, any>;
_httpStatus: string;
_headers: Record<any, any>;
_call: Record<any, any>;
_response: Record<any, any>;
constructor(response: Record<any, any>, call?: Record<any, any>);
_headers: Record<string, any>;
_call: Record<string, any>;
_response: Record<string, any>;
constructor(response: Record<string, any>, call?: Record<string, any>);
/**
* @return {Object} The response body
*/
Expand Down
4 changes: 2 additions & 2 deletions types/facebook-nodejs-business-sdk/src/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ export default class FacebookAdsApi {
* @param {Object} [files]
* @return {Promise}
*/
call(method: string, path: string | string[] | string, params?: Record<any, any>, files?: Record<any, any>, useMultipartFormData?: boolean, urlOverride?: string): Promise<any>;
static _encodeParams(params: Record<any, any>): string;
call(method: string, path: string | string[] | string, params?: Record<string, any>, files?: Record<string, any>, useMultipartFormData?: boolean, urlOverride?: string): Promise<any>;
static _encodeParams(params: Record<string, any>): string;
}
14 changes: 7 additions & 7 deletions types/facebook-nodejs-business-sdk/src/cursor.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import FacebookAdsApi from './api';
export default class Cursor extends Array<Record<any, any>> {
sourceObject: Record<any, any>;
import FacebookAdsApi from "./api";
export default class Cursor extends Array<Record<string, any>> {
sourceObject: Record<string, any>;
_api: FacebookAdsApi;
_targetClass: Record<any, any>;
_targetClass: Record<string, any>;
_loadPage: (path: string) => Promise<any>;
_buildObjectsFromResponse: (response: Record<any, any>) => Array<Record<any, any>>;
_buildObjectsFromResponse: (response: Record<string, any>) => Array<Record<string, any>>;
paging: any;
summary: any;
headers: any;
Expand All @@ -13,12 +13,12 @@ export default class Cursor extends Array<Record<any, any>> {
previous: () => Promise<any>;
hasNext: () => boolean;
hasPrevious: () => boolean;
set: (array: Array<Record<any, any>>) => void;
set: (array: Array<Record<string, any>>) => void;
/**
* @param {Object} sourceObject
* @param {Object} targetClass
* @param {Object} [params]
* @param {String} [endpoint]
*/
constructor(sourceObject: Record<any, any>, targetClass: Record<any, any>, params: Record<any, any>, endpoint?: string | null);
constructor(sourceObject: Record<string, any>, targetClass: Record<string, any>, params: Record<string, any>, endpoint: string | null | undefined);
}
Loading