@pilot-status/sdk 0.15.0 → 0.16.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/CHANGELOG.md +38 -0
- package/README.md +37 -1
- package/dist/client.d.ts +9 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +12 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/ads.d.ts +40 -0
- package/dist/resources/ads.d.ts.map +1 -0
- package/dist/resources/ads.js +67 -0
- package/dist/resources/ads.js.map +1 -0
- package/dist/resources/lead-pages.d.ts +44 -0
- package/dist/resources/lead-pages.d.ts.map +1 -0
- package/dist/resources/lead-pages.js +87 -0
- package/dist/resources/lead-pages.js.map +1 -0
- package/dist/resources/referrals.d.ts +32 -0
- package/dist/resources/referrals.d.ts.map +1 -0
- package/dist/resources/referrals.js +55 -0
- package/dist/resources/referrals.js.map +1 -0
- package/dist/resources/workspace.d.ts +8 -10
- package/dist/resources/workspace.d.ts.map +1 -1
- package/dist/resources/workspace.js +8 -10
- package/dist/resources/workspace.js.map +1 -1
- package/dist/types.d.ts +380 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -1
|
@@ -26,18 +26,16 @@ export declare class WorkspaceMembersResource {
|
|
|
26
26
|
* `requestJson` hands the parsed body straight back. Without the unwrap below,
|
|
27
27
|
* this method resolved to that object while claiming to be an array, so the
|
|
28
28
|
* first `.map()` a caller wrote threw `map is not a function`. Use
|
|
29
|
-
* {@link listWithSeats} when
|
|
29
|
+
* {@link listWithSeats} when `seatsUsed` matters.
|
|
30
30
|
*/
|
|
31
31
|
list(): Promise<WorkspaceMember[]>;
|
|
32
32
|
/**
|
|
33
|
-
* The same call as {@link list}, returning the route's body verbatim so
|
|
34
|
-
*
|
|
33
|
+
* The same call as {@link list}, returning the route's body verbatim so
|
|
34
|
+
* `seatsUsed` / `seatLimit` are not thrown away.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* invites still inside their window — an invite holds its seat, otherwise the
|
|
40
|
-
* cap would be bypassable by mass-inviting.
|
|
36
|
+
* Members are unlimited on every plan: `seatLimit` is `null` and inviting is
|
|
37
|
+
* never refused for capacity. `seatsUsed` is informational — ACTIVE members
|
|
38
|
+
* plus PENDING invites still inside their window.
|
|
41
39
|
*/
|
|
42
40
|
listWithSeats(): Promise<WorkspaceMemberList>;
|
|
43
41
|
}
|
|
@@ -49,8 +47,8 @@ export declare class WorkspaceResource {
|
|
|
49
47
|
/**
|
|
50
48
|
* `GET /v1/workspace` — `{ id, name, plan, seatsUsed, seatLimit }`.
|
|
51
49
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
50
|
+
* Members are unlimited on every plan, so `seatLimit` is `null`. `seatsUsed` is
|
|
51
|
+
* informational: ACTIVE members plus PENDING invites still inside their window.
|
|
54
52
|
*/
|
|
55
53
|
get(): Promise<WorkspaceDetail>;
|
|
56
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEzF;;;;;;;;;;GAUG;AACH,qBAAa,wBAAwB;;gBAGrB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;;;OAaG;IACG,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAKxC
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEzF;;;;;;;;;;GAUG;AACH,qBAAa,wBAAwB;;gBAGrB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;;;OAaG;IACG,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAKxC;;;;;;;OAOG;IACG,aAAa,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAMtD;AAED,wDAAwD;AACxD,qBAAa,iBAAiB;;IAE1B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;gBAE/B,IAAI,EAAE,UAAU;IAK5B;;;;;OAKG;IACG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;CAMxC"}
|
|
@@ -26,21 +26,19 @@ export class WorkspaceMembersResource {
|
|
|
26
26
|
* `requestJson` hands the parsed body straight back. Without the unwrap below,
|
|
27
27
|
* this method resolved to that object while claiming to be an array, so the
|
|
28
28
|
* first `.map()` a caller wrote threw `map is not a function`. Use
|
|
29
|
-
* {@link listWithSeats} when
|
|
29
|
+
* {@link listWithSeats} when `seatsUsed` matters.
|
|
30
30
|
*/
|
|
31
31
|
async list() {
|
|
32
32
|
const page = await this.listWithSeats();
|
|
33
33
|
return page.members;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* The same call as {@link list}, returning the route's body verbatim so
|
|
37
|
-
*
|
|
36
|
+
* The same call as {@link list}, returning the route's body verbatim so
|
|
37
|
+
* `seatsUsed` / `seatLimit` are not thrown away.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* invites still inside their window — an invite holds its seat, otherwise the
|
|
43
|
-
* cap would be bypassable by mass-inviting.
|
|
39
|
+
* Members are unlimited on every plan: `seatLimit` is `null` and inviting is
|
|
40
|
+
* never refused for capacity. `seatsUsed` is informational — ACTIVE members
|
|
41
|
+
* plus PENDING invites still inside their window.
|
|
44
42
|
*/
|
|
45
43
|
async listWithSeats() {
|
|
46
44
|
return this.#http.requestJson({
|
|
@@ -60,8 +58,8 @@ export class WorkspaceResource {
|
|
|
60
58
|
/**
|
|
61
59
|
* `GET /v1/workspace` — `{ id, name, plan, seatsUsed, seatLimit }`.
|
|
62
60
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
61
|
+
* Members are unlimited on every plan, so `seatLimit` is `null`. `seatsUsed` is
|
|
62
|
+
* informational: ACTIVE members plus PENDING invites still inside their window.
|
|
65
63
|
*/
|
|
66
64
|
async get() {
|
|
67
65
|
return this.#http.requestJson({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,wBAAwB;IACxB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,IAAI;QACN,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/resources/workspace.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,wBAAwB;IACxB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,IAAI;QACN,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,uBAAuB;SAChC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,wDAAwD;AACxD,MAAM,OAAO,iBAAiB;IACjB,KAAK,CAAa;IAClB,OAAO,CAA2B;IAE3C,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAkB;YAC3C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe;SACxB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
package/dist/types.d.ts
CHANGED
|
@@ -607,6 +607,12 @@ export type ChatHistoryMessage = {
|
|
|
607
607
|
providerTimestamp: string;
|
|
608
608
|
/** When we ingested it. */
|
|
609
609
|
createdAt: string;
|
|
610
|
+
/**
|
|
611
|
+
* Click-to-WhatsApp provenance: set on the FIRST inbound message of a conversation
|
|
612
|
+
* that started from a Meta ad or post, `null` on every other message. See
|
|
613
|
+
* {@link ChatReferral} and `referrals.list()`.
|
|
614
|
+
*/
|
|
615
|
+
referral?: ChatReferral | null;
|
|
610
616
|
/**
|
|
611
617
|
* Present (and `true`) when the number's PII policy hides this row's content:
|
|
612
618
|
* text, media and peer identity come back `null` but the envelope is kept.
|
|
@@ -1226,6 +1232,365 @@ export type LeadGetResult = {
|
|
|
1226
1232
|
lead: Lead;
|
|
1227
1233
|
notice?: string;
|
|
1228
1234
|
};
|
|
1235
|
+
/**
|
|
1236
|
+
* Click-to-WhatsApp (CTWA) provenance of an inbound message.
|
|
1237
|
+
*
|
|
1238
|
+
* ⚠️ A COPY of `ChatReferralDTO` in the monorepo (`apps/backend/src/lib/chat/referral.ts`);
|
|
1239
|
+
* nothing links them at build time.
|
|
1240
|
+
*
|
|
1241
|
+
* Redaction is SPLIT, not all-or-nothing: on a redacted row `sourceId`/`sourceType` and
|
|
1242
|
+
* the resolved names stay (they identify a creative and the advertiser's own labels, not
|
|
1243
|
+
* a person), while `ctwaClid` and the ad copy come back `null` and `redacted: true` is set.
|
|
1244
|
+
*/
|
|
1245
|
+
export type ChatReferral = {
|
|
1246
|
+
/**
|
|
1247
|
+
* Meta's AD (or post) id — the STABLE identity of the ad. Names are editable in Meta,
|
|
1248
|
+
* so group and match ads by this id, never by name.
|
|
1249
|
+
*/
|
|
1250
|
+
sourceId: string | null;
|
|
1251
|
+
/** `"ad"` | `"post"`, as Meta reports it. */
|
|
1252
|
+
sourceType: string | null;
|
|
1253
|
+
sourceUrl: string | null;
|
|
1254
|
+
headline: string | null;
|
|
1255
|
+
body: string | null;
|
|
1256
|
+
mediaType: string | null;
|
|
1257
|
+
imageUrl: string | null;
|
|
1258
|
+
videoUrl: string | null;
|
|
1259
|
+
thumbnailUrl: string | null;
|
|
1260
|
+
/** Per-click identifier tied to the person — `null` on a redacted row. */
|
|
1261
|
+
ctwaClid: string | null;
|
|
1262
|
+
/**
|
|
1263
|
+
* Names resolved through Meta's Marketing API — only for ad accounts the advertiser
|
|
1264
|
+
* has shared with the Pilot Status business portfolio as a partner (`ads_read`).
|
|
1265
|
+
* `null` when unresolved; see {@link namesResolvedAt}.
|
|
1266
|
+
*/
|
|
1267
|
+
adName: string | null;
|
|
1268
|
+
adsetId: string | null;
|
|
1269
|
+
adsetName: string | null;
|
|
1270
|
+
campaignId: string | null;
|
|
1271
|
+
campaignName: string | null;
|
|
1272
|
+
/**
|
|
1273
|
+
* ISO-8601. Three states: `null` = never resolved (ad account not shared yet, or the
|
|
1274
|
+
* click just arrived); set WITH names = a snapshot taken at that instant; set WITHOUT
|
|
1275
|
+
* names = Meta returned nothing (ad deleted, or the grant is missing / revoked).
|
|
1276
|
+
*/
|
|
1277
|
+
namesResolvedAt: string | null;
|
|
1278
|
+
redacted?: true;
|
|
1279
|
+
};
|
|
1280
|
+
export type ReferralListParams = {
|
|
1281
|
+
/** Only this ad/post id. */
|
|
1282
|
+
sourceId?: string;
|
|
1283
|
+
/** Only paid ads or organic posts. Any other value answers 400 `INVALID_SOURCE_TYPE`. */
|
|
1284
|
+
sourceType?: "ad" | "post";
|
|
1285
|
+
/** ISO 8601. Filters `providerTimestamp`, i.e. when the message happened. */
|
|
1286
|
+
startDate?: string;
|
|
1287
|
+
/** ISO 8601. Must be >= `startDate`, else 400 `INVALID_DATE_RANGE`. */
|
|
1288
|
+
endDate?: string;
|
|
1289
|
+
page?: number;
|
|
1290
|
+
/** Default 30, max 100. */
|
|
1291
|
+
pageSize?: number;
|
|
1292
|
+
};
|
|
1293
|
+
/** An inbound message that arrived from a Click-to-WhatsApp ad or post. */
|
|
1294
|
+
export type ReferralMessage = Omit<ChatHistoryMessage, "referral"> & {
|
|
1295
|
+
referral: ChatReferral;
|
|
1296
|
+
};
|
|
1297
|
+
export type ReferralListResult = {
|
|
1298
|
+
/**
|
|
1299
|
+
* Newest first. Meta attaches the referral to the FIRST message of a conversation
|
|
1300
|
+
* only, so each row amounts to one conversation started by that ad.
|
|
1301
|
+
*/
|
|
1302
|
+
referrals: ReferralMessage[];
|
|
1303
|
+
total: number;
|
|
1304
|
+
page: number;
|
|
1305
|
+
pageSize: number;
|
|
1306
|
+
totalPages: number;
|
|
1307
|
+
/** Only on RELAY_ONLY numbers (`"PII_RELAY_ONLY"`), explaining the redacted rows. */
|
|
1308
|
+
notice?: string;
|
|
1309
|
+
};
|
|
1310
|
+
export type ReferralSummaryParams = {
|
|
1311
|
+
/** ISO 8601. Filters `providerTimestamp`, i.e. when the message happened. */
|
|
1312
|
+
startDate?: string;
|
|
1313
|
+
/** ISO 8601. Must be >= `startDate`, else 400 `INVALID_DATE_RANGE`. */
|
|
1314
|
+
endDate?: string;
|
|
1315
|
+
};
|
|
1316
|
+
/** Click-to-WhatsApp traffic of one ad/post. */
|
|
1317
|
+
export type ReferralSummaryAd = {
|
|
1318
|
+
/** Meta's AD (or post) id — the grouping key. */
|
|
1319
|
+
sourceId: string;
|
|
1320
|
+
sourceType: string | null;
|
|
1321
|
+
/**
|
|
1322
|
+
* DISTINCT conversations — the lead count. Two messages in one conversation are
|
|
1323
|
+
* 1 conversation and 2 `messages`.
|
|
1324
|
+
*/
|
|
1325
|
+
conversations: number;
|
|
1326
|
+
messages: number;
|
|
1327
|
+
/** ISO-8601. */
|
|
1328
|
+
firstAt: string;
|
|
1329
|
+
/** ISO-8601. */
|
|
1330
|
+
lastAt: string;
|
|
1331
|
+
/** From the newest message for this ad (ad copy can be edited). `null` on a RELAY_ONLY number. */
|
|
1332
|
+
lastSourceUrl: string | null;
|
|
1333
|
+
/** From the newest message for this ad. `null` on a RELAY_ONLY number. */
|
|
1334
|
+
lastHeadline: string | null;
|
|
1335
|
+
adName: string | null;
|
|
1336
|
+
adsetId: string | null;
|
|
1337
|
+
adsetName: string | null;
|
|
1338
|
+
campaignId: string | null;
|
|
1339
|
+
campaignName: string | null;
|
|
1340
|
+
/** Same three states as {@link ChatReferral.namesResolvedAt}. */
|
|
1341
|
+
namesResolvedAt: string | null;
|
|
1342
|
+
};
|
|
1343
|
+
export type ReferralSummaryResult = {
|
|
1344
|
+
/** Ordered by `conversations` desc, then `lastAt` desc. */
|
|
1345
|
+
ads: ReferralSummaryAd[];
|
|
1346
|
+
/** Number of entries in `ads`. */
|
|
1347
|
+
total: number;
|
|
1348
|
+
/** The cap on `ads` (200). */
|
|
1349
|
+
limit: number;
|
|
1350
|
+
/**
|
|
1351
|
+
* `true` when more ads matched than `limit`: the answer is PARTIAL. Narrow the window
|
|
1352
|
+
* with `startDate`/`endDate`.
|
|
1353
|
+
*/
|
|
1354
|
+
truncated: boolean;
|
|
1355
|
+
/** Present when `truncated`. */
|
|
1356
|
+
notice?: string;
|
|
1357
|
+
/**
|
|
1358
|
+
* `"PII_RELAY_ONLY"` on a RELAY_ONLY number: counts and names stay correct,
|
|
1359
|
+
* `lastSourceUrl`/`lastHeadline` are `null`.
|
|
1360
|
+
*/
|
|
1361
|
+
piiNotice?: string;
|
|
1362
|
+
};
|
|
1363
|
+
/** An ad account connected to this workspace. */
|
|
1364
|
+
export type LinkedAdAccount = {
|
|
1365
|
+
/** `act_<digits>`. */
|
|
1366
|
+
adAccountId: string;
|
|
1367
|
+
adAccountName: string | null;
|
|
1368
|
+
/** ISO-8601. */
|
|
1369
|
+
linkedAt: string;
|
|
1370
|
+
/**
|
|
1371
|
+
* Whether the partner grant is still in place on Meta's side. `null` = we could not
|
|
1372
|
+
* ask Meta (see `sharingLookup`), NOT "revoked".
|
|
1373
|
+
*/
|
|
1374
|
+
sharingActive: boolean | null;
|
|
1375
|
+
};
|
|
1376
|
+
/**
|
|
1377
|
+
* An ad account shared with the Pilot Status portfolio that provably belongs to this
|
|
1378
|
+
* workspace's own ad traffic, not linked yet. A new workspace gets none — it links by
|
|
1379
|
+
* sending its own `act_` id.
|
|
1380
|
+
*/
|
|
1381
|
+
export type AdAccountCandidate = {
|
|
1382
|
+
adAccountId: string;
|
|
1383
|
+
adAccountName: string | null;
|
|
1384
|
+
/** Meta's numeric account status, passed through (1 = active). */
|
|
1385
|
+
accountStatus: number | null;
|
|
1386
|
+
};
|
|
1387
|
+
export type AdAccountListResult = {
|
|
1388
|
+
linked: LinkedAdAccount[];
|
|
1389
|
+
candidates: AdAccountCandidate[];
|
|
1390
|
+
/**
|
|
1391
|
+
* The Pilot Status business portfolio id — the one the advertiser adds as a PARTNER
|
|
1392
|
+
* (with `ads_read`) of their ad account in Meta Business Manager. `null` when the ads
|
|
1393
|
+
* integration is not configured on this installation.
|
|
1394
|
+
*/
|
|
1395
|
+
partnerBusinessId: string | null;
|
|
1396
|
+
/** `"ok"`, `"unavailable"` (Meta lookup failed) or `"not_configured"`. */
|
|
1397
|
+
sharingLookup: "ok" | "unavailable" | "not_configured";
|
|
1398
|
+
};
|
|
1399
|
+
export type AdAccountLinkResult = {
|
|
1400
|
+
link: {
|
|
1401
|
+
adAccountId: string;
|
|
1402
|
+
adAccountName: string | null;
|
|
1403
|
+
linkedAt: string;
|
|
1404
|
+
};
|
|
1405
|
+
};
|
|
1406
|
+
export type AdAccountUnlinkResult = {
|
|
1407
|
+
unlinked: true;
|
|
1408
|
+
adAccountId: string;
|
|
1409
|
+
};
|
|
1410
|
+
export type AdsSummaryParams = {
|
|
1411
|
+
/**
|
|
1412
|
+
* Restrict to one number. Must be inside the credential's reach, else
|
|
1413
|
+
* 403 `NUMBER_NOT_IN_GRANT`.
|
|
1414
|
+
*/
|
|
1415
|
+
whatsappNumberId?: string;
|
|
1416
|
+
/** ISO 8601. Filters the message time (and the lead's creation time for `leadCount`). */
|
|
1417
|
+
startDate?: string;
|
|
1418
|
+
/** ISO 8601. Must be >= `startDate`, else 400 `INVALID_DATE_RANGE`. */
|
|
1419
|
+
endDate?: string;
|
|
1420
|
+
};
|
|
1421
|
+
/** Click-to-WhatsApp volume of one ad, with its Lead Ads lead count. */
|
|
1422
|
+
export type AdsSummaryAd = ReferralSummaryAd & {
|
|
1423
|
+
/** Leads (Meta Lead Ads) attributed to this ad in the same window. */
|
|
1424
|
+
leadCount: number;
|
|
1425
|
+
};
|
|
1426
|
+
export type AdsSummaryResult = {
|
|
1427
|
+
/** Ordered by `conversations` desc. */
|
|
1428
|
+
ads: AdsSummaryAd[];
|
|
1429
|
+
total: number;
|
|
1430
|
+
/** The cap on `ads` (200). */
|
|
1431
|
+
limit: number;
|
|
1432
|
+
/** `true` = PARTIAL answer; narrow `startDate`/`endDate`. */
|
|
1433
|
+
truncated: boolean;
|
|
1434
|
+
};
|
|
1435
|
+
/** A Facebook Page linked to a WhatsApp number for Meta Lead Ads capture. */
|
|
1436
|
+
export type LeadPageLink = {
|
|
1437
|
+
/** OUR id of the link — the `{pageLinkId}` of the other calls. */
|
|
1438
|
+
pageLinkId: string;
|
|
1439
|
+
pageId: string;
|
|
1440
|
+
pageName: string;
|
|
1441
|
+
whatsappNumberId: string;
|
|
1442
|
+
/** ISO-8601. `null` = Meta is NOT pushing leads for this Page, whatever the link says. */
|
|
1443
|
+
subscribedAt: string | null;
|
|
1444
|
+
/**
|
|
1445
|
+
* Why the subscription is not working: `META_PERMISSION_MISSING`, `META_NOT_FOUND`,
|
|
1446
|
+
* `META_UNAVAILABLE`, `META_NOT_CONFIRMED`, `PAGE_ACCESS_MISSING`, `META_ERROR`,
|
|
1447
|
+
* `NO_OFFICIAL_NUMBER`, `PAGE_NOT_SHARED`, `PAGE_BUSINESS_MISMATCH`. Typed as `string`:
|
|
1448
|
+
* the set can grow.
|
|
1449
|
+
*/
|
|
1450
|
+
subscriptionError: string | null;
|
|
1451
|
+
/** ISO-8601. */
|
|
1452
|
+
linkedAt: string;
|
|
1453
|
+
leadsCount: number;
|
|
1454
|
+
};
|
|
1455
|
+
export type LeadPageCandidate = {
|
|
1456
|
+
pageId: string;
|
|
1457
|
+
pageName: string | null;
|
|
1458
|
+
/** Page tasks our system user still lacks. Empty = ready to link; `null` = could not ask. */
|
|
1459
|
+
missingTasks: string[] | null;
|
|
1460
|
+
};
|
|
1461
|
+
export type LeadPageListResult = {
|
|
1462
|
+
/** Active links, within the credential's number reach. */
|
|
1463
|
+
linked: LeadPageLink[];
|
|
1464
|
+
candidates: LeadPageCandidate[];
|
|
1465
|
+
/** Whether the Lead Ads integration is configured on this installation. */
|
|
1466
|
+
configured: boolean;
|
|
1467
|
+
/** The portfolio the advertiser shares the Page with in Meta Business Manager. */
|
|
1468
|
+
partnerBusinessId: string | null;
|
|
1469
|
+
/** `"ok"`, `"unavailable"` (Meta lookup failed) or `"not_configured"`. */
|
|
1470
|
+
candidatesLookup: "ok" | "unavailable" | "not_configured";
|
|
1471
|
+
/**
|
|
1472
|
+
* `"NO_OFFICIAL_NUMBER"` when the workspace has no official number to prove Page
|
|
1473
|
+
* ownership with (so `candidates` is empty by design), else `null`.
|
|
1474
|
+
*/
|
|
1475
|
+
eligibilityBlocker: string | null;
|
|
1476
|
+
};
|
|
1477
|
+
export type LeadPageLinkInput = {
|
|
1478
|
+
/** The numeric Facebook Page id. */
|
|
1479
|
+
pageId: string;
|
|
1480
|
+
/**
|
|
1481
|
+
* The number that receives the Page's leads. May be omitted only when the credential
|
|
1482
|
+
* reaches exactly one number (a number-bound key, or `whatsappNumberId` on the client).
|
|
1483
|
+
*/
|
|
1484
|
+
whatsappNumberId?: string;
|
|
1485
|
+
};
|
|
1486
|
+
export type LeadPageLinkResult = {
|
|
1487
|
+
link: LeadPageLink;
|
|
1488
|
+
};
|
|
1489
|
+
export type LeadPageUpdateInput = {
|
|
1490
|
+
whatsappNumberId: string;
|
|
1491
|
+
};
|
|
1492
|
+
export type LeadPageUpdateResult = {
|
|
1493
|
+
link: LeadPageLink;
|
|
1494
|
+
/**
|
|
1495
|
+
* `true` = the new number sends a different kind of message (or sits on another WABA)
|
|
1496
|
+
* and every auto-send of this Page's forms was switched OFF.
|
|
1497
|
+
*/
|
|
1498
|
+
autoSendDisabled: boolean;
|
|
1499
|
+
};
|
|
1500
|
+
export type LeadPageUnlinkResult = {
|
|
1501
|
+
unlinked: true;
|
|
1502
|
+
pageLinkId: string;
|
|
1503
|
+
/** Leads of this Page that were ERASED by the unlink. */
|
|
1504
|
+
deletedLeads: number;
|
|
1505
|
+
};
|
|
1506
|
+
export type LeadPageResyncResult = {
|
|
1507
|
+
started: true;
|
|
1508
|
+
pageLinkId: string;
|
|
1509
|
+
/** Present only when the `leadgen` subscription was retried on this call. */
|
|
1510
|
+
subscribedAt?: string | null;
|
|
1511
|
+
/** Present only when the `leadgen` subscription was retried on this call. */
|
|
1512
|
+
subscriptionError?: string | null;
|
|
1513
|
+
};
|
|
1514
|
+
/** Where an auto-send variable takes its value from. */
|
|
1515
|
+
export type LeadVariableSource = {
|
|
1516
|
+
source: "field";
|
|
1517
|
+
key: string;
|
|
1518
|
+
} | {
|
|
1519
|
+
source: "static";
|
|
1520
|
+
value: string;
|
|
1521
|
+
};
|
|
1522
|
+
/** The stored lead configuration of one Instant Form. */
|
|
1523
|
+
export type LeadFormConfig = {
|
|
1524
|
+
formId: string;
|
|
1525
|
+
formName: string | null;
|
|
1526
|
+
consentDisclaimerKey: string | null;
|
|
1527
|
+
autoSendEnabled: boolean;
|
|
1528
|
+
templateId: string | null;
|
|
1529
|
+
freeText: string | null;
|
|
1530
|
+
variableMap: Record<string, LeadVariableSource>;
|
|
1531
|
+
/** ISO-8601. */
|
|
1532
|
+
updatedAt: string;
|
|
1533
|
+
};
|
|
1534
|
+
export type LeadFormQuestion = {
|
|
1535
|
+
key: string;
|
|
1536
|
+
/** Falls back to `key`. */
|
|
1537
|
+
label: string;
|
|
1538
|
+
/** `FULL_NAME`, `EMAIL`, `PHONE`, `CUSTOM`, … */
|
|
1539
|
+
type: string | null;
|
|
1540
|
+
options: {
|
|
1541
|
+
key: string;
|
|
1542
|
+
value: string;
|
|
1543
|
+
}[];
|
|
1544
|
+
};
|
|
1545
|
+
export type LeadForm = {
|
|
1546
|
+
formId: string;
|
|
1547
|
+
formName: string | null;
|
|
1548
|
+
status: string | null;
|
|
1549
|
+
questions: LeadFormQuestion[];
|
|
1550
|
+
consentCheckboxes: {
|
|
1551
|
+
key: string;
|
|
1552
|
+
text: string | null;
|
|
1553
|
+
}[];
|
|
1554
|
+
/** `false` = Meta did not return the consent checkboxes: the list is UNKNOWN, not empty. */
|
|
1555
|
+
consentAvailable: boolean;
|
|
1556
|
+
/** `null` = this form was never configured. */
|
|
1557
|
+
config: LeadFormConfig | null;
|
|
1558
|
+
};
|
|
1559
|
+
export type LeadFormListResult = {
|
|
1560
|
+
/** Live from Meta. */
|
|
1561
|
+
forms: LeadForm[];
|
|
1562
|
+
/** `true` when the Page has more forms than were read. */
|
|
1563
|
+
formsTruncated: boolean;
|
|
1564
|
+
/** Official (Cloud API) numbers auto-send templates only; the others, free text only. */
|
|
1565
|
+
numberIsOfficial: boolean;
|
|
1566
|
+
/** APPROVED templates the link's number can auto-send. Empty on a non-official number. */
|
|
1567
|
+
templates: {
|
|
1568
|
+
id: string;
|
|
1569
|
+
name: string;
|
|
1570
|
+
variables: string[];
|
|
1571
|
+
}[];
|
|
1572
|
+
};
|
|
1573
|
+
/**
|
|
1574
|
+
* `PUT /v1/lead-pages/{pageLinkId}/forms/{formId}` — create or REPLACE the whole config.
|
|
1575
|
+
* ⚠️ A config the API accepts WILL message new leads without a human when
|
|
1576
|
+
* `autoSendEnabled` is `true`.
|
|
1577
|
+
*/
|
|
1578
|
+
export type LeadFormConfigInput = {
|
|
1579
|
+
/** Key of the consent checkbox that gates the auto-send, or `null`. */
|
|
1580
|
+
consentDisclaimerKey: string | null;
|
|
1581
|
+
autoSendEnabled: boolean;
|
|
1582
|
+
/** An APPROVED template (official numbers), or `null`. */
|
|
1583
|
+
templateId: string | null;
|
|
1584
|
+
/** Free text with `{{placeholders}}` (non-official numbers), max 4096, or `null`. */
|
|
1585
|
+
freeText: string | null;
|
|
1586
|
+
/** Value of each template / free-text variable. Defaults to `{}`. */
|
|
1587
|
+
variableMap?: Record<string, LeadVariableSource>;
|
|
1588
|
+
/** Display label, max 255. */
|
|
1589
|
+
formName?: string | null;
|
|
1590
|
+
};
|
|
1591
|
+
export type LeadFormConfigResult = {
|
|
1592
|
+
config: LeadFormConfig;
|
|
1593
|
+
};
|
|
1229
1594
|
/**
|
|
1230
1595
|
* `"META_24H"` = Meta's rule genuinely applies. `"NONE"` = web/unofficial number,
|
|
1231
1596
|
* where the restriction does not exist and `open` is always `true`.
|
|
@@ -1442,9 +1807,16 @@ export type WorkspaceDetail = {
|
|
|
1442
1807
|
/** `null` while the tenant has no name set — the route sends `tenant?.name ?? null`. */
|
|
1443
1808
|
name: string | null;
|
|
1444
1809
|
plan: string;
|
|
1445
|
-
/**
|
|
1810
|
+
/**
|
|
1811
|
+
* Informational: ACTIVE members plus PENDING invites still inside their window.
|
|
1812
|
+
* Nothing caps it — members are unlimited on every plan.
|
|
1813
|
+
*/
|
|
1446
1814
|
seatsUsed: number;
|
|
1447
|
-
|
|
1815
|
+
/**
|
|
1816
|
+
* `null` = unlimited, which is what the API sends on every plan. Typed `number | null`
|
|
1817
|
+
* only because servers that predate unlimited members sent a number.
|
|
1818
|
+
*/
|
|
1819
|
+
seatLimit: number | null;
|
|
1448
1820
|
};
|
|
1449
1821
|
/**
|
|
1450
1822
|
* An active member or a pending invite — the same list, discriminated by `status`.
|
|
@@ -1473,19 +1845,20 @@ export type WorkspaceMember = {
|
|
|
1473
1845
|
joinedAt: string | null;
|
|
1474
1846
|
/** `null` once the invite has been accepted (the token is burned on acceptance). */
|
|
1475
1847
|
inviteExpiresAt: string | null;
|
|
1476
|
-
/** `true` when the invite lapsed: the row survives but
|
|
1848
|
+
/** `true` when the invite lapsed: the row survives but no longer counts in `seatsUsed`. */
|
|
1477
1849
|
inviteExpired: boolean;
|
|
1478
1850
|
};
|
|
1479
1851
|
/**
|
|
1480
1852
|
* The literal body of `GET /v1/workspace/members` — an ENVELOPE, not a bare
|
|
1481
|
-
* array. `seatsUsed`/`seatLimit` are the same
|
|
1482
|
-
* reports
|
|
1483
|
-
*
|
|
1853
|
+
* array. `seatsUsed`/`seatLimit` are the same values `GET /v1/workspace`
|
|
1854
|
+
* reports: `seatsUsed` is informational and `seatLimit` is `null` (unlimited
|
|
1855
|
+
* members, on every plan).
|
|
1484
1856
|
*/
|
|
1485
1857
|
export type WorkspaceMemberList = {
|
|
1486
1858
|
members: WorkspaceMember[];
|
|
1487
1859
|
seatsUsed: number;
|
|
1488
|
-
seatLimit
|
|
1860
|
+
/** `null` = unlimited. See {@link WorkspaceDetail.seatLimit}. */
|
|
1861
|
+
seatLimit: number | null;
|
|
1489
1862
|
};
|
|
1490
1863
|
/**
|
|
1491
1864
|
* Meta's closed set. A value outside it only fails AFTER the trip to the Graph,
|