ab-ecosystem-cpass 1.0.12 → 1.0.13

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 +1 @@
1
- {"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../../src/resources/channels/onboarding.ts"],"names":[],"mappings":";;;AAYA,oCAAoC;AACpC,oEAAoF;AAEpF,MAAM,UAAU,GAAG,GAAG,gBAAQ,aAAa,CAAC;AAY5C;;;;;;;;;;;;;;GAcG;AACH,MAAa,iBAAiB;IACC;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsC,KAAK,EAAE,GAAG,UAAU,QAAQ,CAAC,CAAC;IAC9F,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,QAA4B,EAAE;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAgC,MAAM,EAAE,GAAG,UAAU,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACxG,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAA8B;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAqC,MAAM,EAAE,GAAG,UAAU,WAAW,EAAE;YAC7F,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAA8B;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAkB,MAAM,EAAE,GAAG,UAAU,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,UAA0B,EAAE;QACxC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QACtD,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AU,YAAY,kBAAkB,CAAC,KAAK,CAAC,EAAE,CACrD,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,KAA8B;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAqC,MAAM,EAAE,GAAG,UAAU,WAAW,EAAE;YAC7F,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAA8B;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAkB,MAAM,EAAE,GAAG,UAAU,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,OAAuB;QACnC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QAChE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;QAEhF,MAAM,QAAQ,GAAG,MAAM,IAAA,mCAAiB,EAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YACpB,MAAM,IAAI,qCAAmB,CAAC,cAAc,EAAE,kDAAkD,CAAC,CAAC;QACpG,CAAC;QAED,gEAAgE;QAChE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEpD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5ED,8CA4EC"}
@@ -108,6 +108,14 @@ export interface CampaignTriggerInfo {
108
108
  }
109
109
  export interface Campaign {
110
110
  id: string;
111
+ /**
112
+ * The team member who created the campaign, by psuid. Absent when the account
113
+ * holder created it, and on campaigns written before this was recorded.
114
+ *
115
+ * Who *wrote* it. Who armed it is `triggerInfo.psuid`, which can be someone
116
+ * else and is set a step later.
117
+ */
118
+ member?: string;
111
119
  version: string;
112
120
  crmVersion: string;
113
121
  name: string;
@@ -49,6 +49,12 @@ export interface ChannelWallet {
49
49
  */
50
50
  export interface Channel {
51
51
  id: string;
52
+ /**
53
+ * The team member who connected the channel, by psuid. Absent when the
54
+ * account holder connected it, and on channels created before this was
55
+ * recorded.
56
+ */
57
+ member?: string;
52
58
  /** Enabled/disabled by the owner -- not the connection state. */
53
59
  active: boolean;
54
60
  ecom?: {
@@ -385,38 +391,68 @@ export interface ListActivityLogsQuery extends ListQuery {
385
391
  export type OnboardingChannelType = 'whatsapp';
386
392
  /** Every family the picker shows, implemented or not. */
387
393
  export type OfferableChannelType = 'whatsapp' | 'facebook' | 'instagram';
388
- /** Why a family cannot be connected right now. */
389
- export type OnboardingUnavailableReason = 'not_included' | 'quota_exceeded' | 'not_supported' | 'provider_not_configured' | 'not_permitted';
390
- /** One row of the "add a channel" picker. */
394
+ /** One row of the "add a channel" picker. Only connectable families are listed. */
391
395
  export interface ChannelOnboardingOption {
392
396
  type: OfferableChannelType;
393
397
  label: string;
394
- available: boolean;
395
398
  /** The inclusion a channel would be created against. Pass back to `url()`. */
396
399
  slug?: string;
397
400
  limit?: number;
398
401
  used?: number;
399
402
  remaining?: number;
400
- /** Set only when `available` is false. */
401
- reason?: OnboardingUnavailableReason;
402
403
  }
403
404
  export interface OnboardingUrlInput {
404
405
  type?: OnboardingChannelType;
405
406
  /** Only needed when the plan carries more than one channel inclusion. */
406
407
  slug?: string;
407
- /** Must be one of the service's configured redirects. Omit for the default. */
408
- redirectUri?: string;
408
+ /**
409
+ * Which BSP to connect through, by provider code. Omit for whichever is
410
+ * active for this family -- pin one only when there is a reason to.
411
+ */
412
+ provider?: string;
413
+ /**
414
+ * Where the browser is handed back, with the outcome on it. **Required**: the
415
+ * callback has no session, so nothing else says where. Meta never sees it.
416
+ */
417
+ redirectUri: string;
409
418
  }
410
419
  export interface OnboardingUrlResult {
411
- /** Open in a popup. Meta refuses to render the dialog in an iframe. */
420
+ /**
421
+ * Open in a popup, or navigate to it; it cannot be framed. A launcher on the
422
+ * app's own domain that forwards to `dialogUrl`, since Meta ties the dialog
423
+ * to that domain.
424
+ */
412
425
  url: string;
413
- /** Opaque; hand back to `exchange()` unchanged. */
426
+ /** Meta's dialog, which `url` forwards to. Open `url`, not this. */
427
+ dialogUrl: string;
428
+ /** Opaque, and already carrying `redirectUri`. Our callback is what reads it. */
414
429
  state: string;
430
+ /** Where the browser will come back to. */
415
431
  redirectUri: string;
432
+ /** What Meta was given: the service's own callback, registered on the BSP app. */
433
+ callbackUri: string;
416
434
  expiresAt: IsoDate;
417
435
  provider: string;
418
436
  remaining?: number;
419
437
  }
438
+ /** `ready`: one number, bound. `select`: several, so `complete()` names one. */
439
+ export type OnboardingReturnStatus = 'ready' | 'select' | 'error';
440
+ /** The query string the service appends to `redirectUri`. All values are strings. */
441
+ export interface OnboardingReturn {
442
+ status: OnboardingReturnStatus;
443
+ /** Pass to `pending()`, and to `complete()` as `token`. */
444
+ token?: string;
445
+ /** How many numbers the authorisation covered; `"1"` for `ready`. */
446
+ numbers?: string;
447
+ wabaId?: string;
448
+ phoneNumberId?: string;
449
+ displayPhoneNumber?: string;
450
+ verifiedName?: string;
451
+ expiresAt?: string;
452
+ /** `status=error` only. */
453
+ code?: string;
454
+ message?: string;
455
+ }
420
456
  /** What Meta reports about the number, for the confirmation card. */
421
457
  export interface OnboardingPhoneNumber {
422
458
  id: string;
@@ -434,21 +470,35 @@ export interface OnboardingExchangeInput {
434
470
  wabaId: string;
435
471
  phoneNumberId: string;
436
472
  }
473
+ /** Prefill for the final form. Every field is overridable in `complete()`. */
474
+ export interface OnboardingDefaults {
475
+ name: string;
476
+ color: string;
477
+ currency: ChannelCurrency;
478
+ }
437
479
  export interface OnboardingExchangeResult {
438
480
  /** The pending record's id. Pass to `complete()` as `token`. */
439
481
  id: string;
440
482
  expiresAt: IsoDate;
441
483
  phoneNumber: OnboardingPhoneNumber;
442
- /** Prefill for the final form. */
443
- defaults: {
444
- name: string;
445
- color: string;
446
- currency: ChannelCurrency;
447
- };
484
+ defaults: OnboardingDefaults;
485
+ }
486
+ /** A pending record, read back from the `token` on the return URL. */
487
+ export interface OnboardingPendingResult {
488
+ id: string;
489
+ expiresAt: IsoDate;
490
+ type: OnboardingChannelType;
491
+ /** Every number the authorisation covers that is still free to connect. */
492
+ numbers: OnboardingPhoneNumber[];
493
+ /** Set when there was exactly one, and so already bound to the record. */
494
+ phoneNumber?: OnboardingPhoneNumber;
495
+ defaults: OnboardingDefaults;
448
496
  }
449
497
  export interface CompleteOnboardingInput {
450
- /** The `id` from `exchange()`. */
498
+ /** The `id` from `exchange()`, or `token` off the return URL. */
451
499
  token: string;
500
+ /** Which number, when the record covers several -- `status=select`. */
501
+ phoneNumberId?: string;
452
502
  name: string;
453
503
  color?: string;
454
504
  currency?: ChannelCurrency;
@@ -1 +1 @@
1
- {"version":3,"file":"channels.js","sourceRoot":"","sources":["../../src/types/channels.ts"],"names":[],"mappings":";;;AA8KA;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,CAAC,aAAa,EAAE,kBAAkB,EAAE,cAAc,CAAU,CAAC;AAoIpF,QAAA,sBAAsB,GAAmC;IACpE,UAAU;IACV,MAAM;IACN,WAAW;IACX,MAAM;IACN,QAAQ;IACR,SAAS;IACT,UAAU;IACV,SAAS;IACT,cAAc;IACd,OAAO;CACR,CAAC"}
1
+ {"version":3,"file":"channels.js","sourceRoot":"","sources":["../../src/types/channels.ts"],"names":[],"mappings":";;;AAoLA;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,CAAC,aAAa,EAAE,kBAAkB,EAAE,cAAc,CAAU,CAAC;AAoIpF,QAAA,sBAAsB,GAAmC;IACpE,UAAU;IACV,MAAM;IACN,WAAW;IACX,MAAM;IACN,QAAQ;IACR,SAAS;IACT,UAAU;IACV,SAAS;IACT,cAAc;IACd,OAAO;CACR,CAAC"}
@@ -41,6 +41,12 @@ account's and not visible to an `own`-scoped member. Reading, updating or
41
41
  deleting a contact outside that scope is `404`, never `403`: a `403` would
42
42
  confirm the contact exists, which is what the scope is hiding.
43
43
 
44
+ A contact a **team member** creates is assigned to that member as its `agent`,
45
+ whatever their `data_scope` and whatever `agent` the body carried: they are the
46
+ one working it. An account holder's create leaves `agent` as given — `null`
47
+ unless they named someone — so a contact stays unassigned until it is handed
48
+ over.
49
+
44
50
 
45
51
  ## The contact object
46
52
 
@@ -168,7 +174,7 @@ blank contact.
168
174
  | `whatsapp` | string | — | The contact's WhatsApp number, in any shape. Creates the channel identity. Create-only. |
169
175
  | `order` | string | — | Free-form external reference. |
170
176
  | `tags` | ObjectId[] | `[]` | Contact tag ids. |
171
- | `agent` | ObjectId \| null | — | Assigned agent. |
177
+ | `agent` | ObjectId \| null | — | Assigned agent. **Ignored for a team member**: the member creating the contact is assigned it. |
172
178
  | `team` | ObjectId \| null | — | Assigned team. |
173
179
  | `lead_source` | `{ type?, module?, id? }` | — | Where the contact came from. |
174
180
  | `status` | `'live' \| 'trashed'` | `'live'` | |
@@ -67,8 +67,15 @@ named against it.
67
67
  | --- | --- | --- |
68
68
  | `scheduledAt` in the body | **`422`** | that is the point |
69
69
  | writes `triggerInfo` | no | yes |
70
+ | writes `member` | on `create`, by a team member | no |
70
71
  | campaign becomes sendable | no | yes |
71
72
 
73
+ `member` is the other half of that record: the team member who **wrote** the
74
+ campaign, stamped at `create` from their token. `triggerInfo.psuid` is who armed
75
+ it, which is a later act and can be somebody else. Both are server-set and
76
+ refused from a body; an account holder's campaign carries no `member`, because
77
+ the campaign is already theirs.
78
+
72
79
  **"Now" is not instant.** `trigger` with no time arms the campaign about a minute
73
80
  out (`CAMPAIGN_IMMEDIATE_DELAY_SECONDS`), and [`cancel`](#cancel) still stops it
74
81
  in that window. A second `trigger` on a campaign that is armed but not yet picked
@@ -64,6 +64,7 @@ remains is safe to hand a console.
64
64
  ```ts
65
65
  interface Channel {
66
66
  id: string;
67
+ member?: string; // the team member who connected it; absent when the account holder did
67
68
  active: boolean; // enabled by the owner — NOT the connection state
68
69
  ecom?: { store_status: boolean; store?: string };
69
70
  basic_details: { name: string; color_code: string; channel_identity: string };