Skip to content

Commit

Permalink
fix ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rodinhatokay committed Jun 27, 2024
1 parent 42b661a commit c559fd2
Show file tree
Hide file tree
Showing 76 changed files with 406 additions and 403 deletions.
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,7 +20,7 @@ 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 fbAdAccount = new AdAccount(`act_ID`, {}, undefined, fbAdsApi);
const cursor = await fbAdAccount.getAds(['id', 'name'], { limit: 10 }, false);

while (cursor.hasNext()) {
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('joe@eg.com','','','','','','','','','','','','','','','','','','','','','','','','',''))
.setEmails(['joe@eg.com'])
.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
14 changes: 7 additions & 7 deletions types/facebook-nodejs-business-sdk/src/api-batch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ declare class FacebookAdsApiBatch {
* @return {Object} An object describing the call
*/
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: void | string;
body: void | string;
attachedFiles: undefined | string;
body: undefined | string;
method: string;
name: void | any;
name: any;
relative_url: string;
};
/**
Expand All @@ -52,10 +52,10 @@ declare class FacebookAdsApiBatch {
* @return {Object} An object describing the call
*/
addRequest(request: APIRequest, successCallback?: (...args: any[]) => any, failureCallback?: (...args: any[]) => any): {
attachedFiles: void | string;
body: void | string;
attachedFiles: undefined | string;
body: undefined | string;
method: string;
name: void | any;
name: any;
relative_url: string;
};
/**
Expand All @@ -69,6 +69,6 @@ declare class FacebookAdsApiBatch {
* returns a new FacebookAdsApiBatch object with those calls.
* Otherwise, returns None.
*/
execute(): void | Promise<unknown>;
execute(): undefined | Promise<unknown>;
}
export default FacebookAdsApiBatch;
2 changes: 1 addition & 1 deletion 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<string, any>, files?: Record<string, any>, useMultipartFormData?: boolean, urlOverride?: string): Promise<any>;
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class AdAsyncRequestSet extends AbstractCrudObject {
on_complete: "ON_COMPLETE";
}>;
getRequests(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
delete(fields: string[], params?: Record<string, any>): AbstractObject;
get(fields: string[], params?: Record<string, any>): Promise<AbstractObject>;
get(fields: string[], params?: Record<string, any>): Promise<AdAsyncRequestSet>;
update(fields: string[], params?: Record<string, any>): Promise<AdAsyncRequestSet>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export default class AdAsyncRequest extends AbstractCrudObject {
user_canceled: "USER_CANCELED";
user_canceled_dependency: "USER_CANCELED_DEPENDENCY";
}>;
delete(fields: string[], params?: Record<string, any>): AbstractObject;
get(fields: string[], params?: Record<string, any>): Promise<AbstractObject>;
get(fields: string[], params?: Record<string, any>): Promise<AdAsyncRequest>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ export default class AdCreative extends AbstractCrudObject {
all: "ALL";
any: "ANY";
}>;
createAdLabel(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdCreative>;
createAdLabel(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdCreative>;
getCreativeInsights(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getPreviews(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
delete(fields: string[], params?: Record<string, any>): AbstractObject;
get(fields: string[], params?: Record<string, any>): Promise<AbstractObject>;
get(fields: string[], params?: Record<string, any>): Promise<AdCreative>;
update(fields: string[], params?: Record<string, any>): Promise<AdCreative>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class AdLabel extends AbstractCrudObject {
getAds(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getAdSets(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getCampaigns(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
delete(fields: string[], params?: Record<string, any>): AbstractObject;
get(fields: string[], params?: Record<string, any>): Promise<AbstractObject>;
get(fields: string[], params?: Record<string, any>): Promise<AdLabel>;
update(fields: string[], params?: Record<string, any>): Promise<AdLabel>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class AdMonetizationProperty extends AbstractCrudObject {
id: "id";
}>;
getAdNetworkAnalytics(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createAdNetworkAnalytic(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdMonetizationProperty>;
createAdNetworkAnalytic(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdMonetizationProperty>;
getAdNetworkAnalyticsResults(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
get(fields: string[], params?: Record<string, any>): Promise<AdMonetizationProperty>;
}
6 changes: 3 additions & 3 deletions types/facebook-nodejs-business-sdk/src/objects/ad-rule.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export default class AdRule extends AbstractCrudObject {
rule_syd_redirect: "RULE_SYD_REDIRECT";
rule_templates_dialog: "RULE_TEMPLATES_DIALOG";
}>;
createExecute(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AbstractObject>;
createExecute(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AbstractObject>;
getHistory(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createPreview(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdRule>;
delete(fields: string[], params?: Record<string, any>): AbstractObject;
createPreview(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdRule>;
get(fields: string[], params?: Record<string, any>): Promise<AbstractObject>;
get(fields: string[], params?: Record<string, any>): Promise<AdRule>;
update(fields: string[], params?: Record<string, any>): Promise<AdRule>;
}
10 changes: 5 additions & 5 deletions types/facebook-nodejs-business-sdk/src/objects/ad-set.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,18 @@ export default class AdSet extends AbstractCrudObject {
getAdStudies(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getAdCreatives(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
deleteAdLabels(params?: Record<string, any>): Promise<any>;
createAdLabel(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdSet>;
createAdLabel(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdSet>;
getAdRulesGoverned(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getAds(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getAsyncAdRequests(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createBudgetSchedule(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<HighDemandPeriod>;
createBudgetSchedule(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<HighDemandPeriod>;
getCopies(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createCopy(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdSet>;
createCopy(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdSet>;
getDeliveryEstimate(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getInsights(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getInsightsAsync(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdReportRun>;
getInsightsAsync(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdReportRun>;
getTargetingSentenceLines(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
delete(fields: string[], params?: Record<string, any>): AbstractObject;
get(fields: string[], params?: Record<string, any>): Promise<AbstractObject>;
get(fields: string[], params?: Record<string, any>): Promise<AdSet>;
update(fields: string[], params?: Record<string, any>): Promise<AdSet>;
}
6 changes: 3 additions & 3 deletions types/facebook-nodejs-business-sdk/src/objects/ad-study.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export default class AdStudy extends AbstractCrudObject {
split_test: "SPLIT_TEST";
}>;
getCells(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createCheckPoint(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdStudy>;
createCheckPoint(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdStudy>;
getInstances(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createInstance(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<PrivateLiftStudyInstance>;
createInstance(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<PrivateLiftStudyInstance>;
getObjectives(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
delete(fields: string[], params?: Record<string, any>): AbstractObject;
get(fields: string[], params?: Record<string, any>): Promise<AbstractObject>;
get(fields: string[], params?: Record<string, any>): Promise<AdStudy>;
update(fields: string[], params?: Record<string, any>): Promise<AdStudy>;
}
8 changes: 4 additions & 4 deletions types/facebook-nodejs-business-sdk/src/objects/ad.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ export default class Ad extends AbstractCrudObject {
paused: "PAUSED";
}>;
getAdCreatives(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createAdLabel(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<Ad>;
createAdLabel(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<Ad>;
getAdRulesGoverned(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getCopies(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createCopy(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<Ad>;
createCopy(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<Ad>;
getInsights(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getInsightsAsync(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdReportRun>;
getInsightsAsync(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdReportRun>;
getLeads(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getPreviews(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getTargetingSentenceLines(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
delete(fields: string[], params?: Record<string, any>): AbstractObject;
get(fields: string[], params?: Record<string, any>): Promise<AbstractObject>;
get(fields: string[], params?: Record<string, any>): Promise<Ad>;
update(fields: string[], params?: Record<string, any>): Promise<Ad>;
}
12 changes: 6 additions & 6 deletions types/facebook-nodejs-business-sdk/src/objects/ads-pixel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ export default class AdsPixel extends AbstractCrudObject {
getAdAccounts(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
deleteAgencies(params?: Record<string, any>): Promise<any>;
getAgencies(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createAgency(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdsPixel>;
createAhpConfig(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AbstractObject>;
createAgency(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdsPixel>;
createAhpConfig(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AbstractObject>;
getAssignedUsers(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createAssignedUser(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdsPixel>;
createAssignedUser(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdsPixel>;
getDaChecks(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createEvent(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AbstractObject>;
createEvent(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AbstractObject>;
getOfflineEventUploads(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getOpenBridgeConfigurations(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createShadowTrafficHelper(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AbstractObject>;
createShadowTrafficHelper(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AbstractObject>;
deleteShareDAccounts(params?: Record<string, any>): Promise<any>;
getShareDAccounts(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createShareDAccount(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<AdsPixel>;
createShareDAccount(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<AdsPixel>;
getShareDAgencies(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
getStats(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
get(fields: string[], params?: Record<string, any>): Promise<AdsPixel>;
Expand Down
6 changes: 3 additions & 3 deletions types/facebook-nodejs-business-sdk/src/objects/album.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export default class Album extends AbstractCrudObject {
video_count: "video_count";
}>;
getComments(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createComment(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<Comment>;
createComment(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<Comment>;
getLikes(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createLike(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<Album>;
createLike(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<Album>;
getPhotos(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
createPhoto(fields: string[], params?: Record<string, any>, pathOverride?: string | null | undefined): Promise<Photo>;
createPhoto(fields: string[], params?: Record<string, any>, pathOverride?: string | null): Promise<Photo>;
getPicture(fields: string[], params?: Record<string, any>, fetchFirstPage?: boolean): Cursor | Promise<Cursor>;
get(fields: string[], params?: Record<string, any>): Promise<Album>;
}
Loading

0 comments on commit c559fd2

Please sign in to comment.