@whooshbang/sdk 5.1.0 → 7.0.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.
Files changed (73) hide show
  1. package/README.md +232 -83
  2. package/dist/cli/commands.js +2 -0
  3. package/dist/cli/commands.js.map +1 -1
  4. package/dist/client.d.ts +169 -1
  5. package/dist/client.js +534 -4
  6. package/dist/client.js.map +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/interactions.js +18 -3
  10. package/dist/interactions.js.map +1 -1
  11. package/dist/recipient/digest-section.d.ts +29 -0
  12. package/dist/recipient/digest-section.js +400 -0
  13. package/dist/recipient/digest-section.js.map +1 -0
  14. package/dist/recipient/element.js +784 -14
  15. package/dist/recipient/element.js.map +1 -1
  16. package/dist/recipient/i18n/ar.js +114 -0
  17. package/dist/recipient/i18n/ar.js.map +1 -1
  18. package/dist/recipient/i18n/catalog.d.ts +113 -0
  19. package/dist/recipient/i18n/catalog.js.map +1 -1
  20. package/dist/recipient/i18n/de.js +119 -0
  21. package/dist/recipient/i18n/de.js.map +1 -1
  22. package/dist/recipient/i18n/en.js +119 -0
  23. package/dist/recipient/i18n/en.js.map +1 -1
  24. package/dist/recipient/i18n/es.js +119 -0
  25. package/dist/recipient/i18n/es.js.map +1 -1
  26. package/dist/recipient/i18n/fa.js +114 -0
  27. package/dist/recipient/i18n/fa.js.map +1 -1
  28. package/dist/recipient/i18n/fr.js +119 -0
  29. package/dist/recipient/i18n/fr.js.map +1 -1
  30. package/dist/recipient/i18n/hi.js +119 -0
  31. package/dist/recipient/i18n/hi.js.map +1 -1
  32. package/dist/recipient/i18n/id.js +119 -0
  33. package/dist/recipient/i18n/id.js.map +1 -1
  34. package/dist/recipient/i18n/it.js +119 -0
  35. package/dist/recipient/i18n/it.js.map +1 -1
  36. package/dist/recipient/i18n/nl.js +119 -0
  37. package/dist/recipient/i18n/nl.js.map +1 -1
  38. package/dist/recipient/i18n/pl.js +119 -0
  39. package/dist/recipient/i18n/pl.js.map +1 -1
  40. package/dist/recipient/i18n/pt-BR.js +119 -0
  41. package/dist/recipient/i18n/pt-BR.js.map +1 -1
  42. package/dist/recipient/i18n/ru.js +119 -0
  43. package/dist/recipient/i18n/ru.js.map +1 -1
  44. package/dist/recipient/i18n/tr.js +119 -0
  45. package/dist/recipient/i18n/tr.js.map +1 -1
  46. package/dist/recipient/i18n/uk.js +119 -0
  47. package/dist/recipient/i18n/uk.js.map +1 -1
  48. package/dist/recipient/i18n/zh-Hans.js +114 -0
  49. package/dist/recipient/i18n/zh-Hans.js.map +1 -1
  50. package/dist/recipient/mount.d.ts +5 -0
  51. package/dist/recipient/mount.js +2 -0
  52. package/dist/recipient/mount.js.map +1 -1
  53. package/dist/recipient/order-section.d.ts +41 -0
  54. package/dist/recipient/order-section.js +547 -0
  55. package/dist/recipient/order-section.js.map +1 -0
  56. package/dist/recipient/order-view.d.ts +123 -0
  57. package/dist/recipient/order-view.js +304 -0
  58. package/dist/recipient/order-view.js.map +1 -0
  59. package/dist/recipient/platform-mark.d.ts +1 -0
  60. package/dist/recipient/platform-mark.js +57 -0
  61. package/dist/recipient/platform-mark.js.map +1 -0
  62. package/dist/recipient/quiet-section.d.ts +51 -0
  63. package/dist/recipient/quiet-section.js +617 -0
  64. package/dist/recipient/quiet-section.js.map +1 -0
  65. package/dist/recipient/quiet-view.d.ts +104 -0
  66. package/dist/recipient/quiet-view.js +304 -0
  67. package/dist/recipient/quiet-view.js.map +1 -0
  68. package/dist/recipient/view.d.ts +2 -0
  69. package/dist/recipient/view.js.map +1 -1
  70. package/dist/webhooks.d.ts +30 -1
  71. package/dist/webhooks.js +57 -4
  72. package/dist/webhooks.js.map +1 -1
  73. package/package.json +12 -2
package/dist/client.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { validateWhoAmI, validateOperatorCollection, validateOperatorResolution, validateCreateOperatorMessageRequest, validateOperatorMessageResult, validateOperatorBroadcast, validateOperatorPreferences, validateOperatorConnectRequest, } from "@whooshbang/contracts";
2
2
  import { validateAssertEmailConsentRequest, validateBindingSummary, } from "@whooshbang/contracts";
3
- import { contractValidationErrors, validateOrganizationCredential, validateOrganizationCredentialCollection, validateOrganizationCredentialRotation, validateOrganizationCredentialSecretReveal, validateBillingProjectSlots, validateBillingPromotions, validateBillingPromotion, validateRedeemBillingPromotionRequest, validateAssignBillingProjectSlotsRequest, validateSubscriptionChange, validateConfirmSubscriptionChangeRequest, validateBillingEntitlements, validateSubscriptionSelection, validateProjectAttribution, validateUpdateProjectAttributionRequest, validateAutoTopUpSettings, validateUpdateAutoTopUpSettingsRequest, validateBillingAccount, validateCardSetup, validateCreateCreditPurchaseRequest, validateCreditPurchase, validateBillingInvoiceCollection, validateUpdateBillingReceiptEmailRequest, validateOrganizationProjection, validateApiCredential, validateApiCredentialCollection, validateApiCredentialRotation, validateApiCredentialSecretReveal, validateAttachNotifierConnectionRequest, validateChannelConnection, validateChannelConnectionCollection, validateConnectionProviderCollection, validateUsageReport, validateMessageListPage, validateMessageDeliveryHistory, validateMessageNotificationImage, validateInteractionTimeline, validateUpdateEmailSenderRequest, validateCustomerEventDeliveryHistory, validateCustomerEventDeliveryAttempt, validateDeliveryHolds, validateMachineClientOperationsList, validateRecipientCopyCatalogue, validateNotifierConnectionCollection, validateProjectRecipientExperience, validateRecipientBrandLogoUpload, validateNotificationImageAsset, validateUpdateProjectRecipientExperienceRequest, validateEnvironmentRecipientExperience, validateUpdateEnvironmentRecipientExperienceRequest, validateSubscriberChannelSettings, validateAcknowledgeEmailRemediationRequest, validateCreateRecipientSessionRequest, validateCreateRecipientSessionResponse, validateRecipientSession, validateCreateProviderHandoffRequest, validateProviderHandoff, validateSetPreferredBindingRequest, validatePreferredBinding, validateCreateSubscriberRequest, validateSubscriber, validateSubscriberDataExport, validateUpdateSubscriberRequest, validateSubscriberCollection, validateCloseOrganizationRequest, validateInviteTeammateRequest, validateTeammate, validateTeammateAccessRequest, validateTeammateCollection, validateOrganizationClosureResult, validateCreateSubscriberGroupRequest, validateUpdateSubscriberGroupRequest, validateSubscriberGroup, validateSubscriberGroupCollection, validateSubscriberGroupMembership, validateSubscriberGroupMembershipCollection, validateCreateGroupBroadcastRequest, validateGroupBroadcast, validateCreateOrganizationCredentialRequest, validateCreateApiCredentialRequest, validateCreateChannelConnectionRequest, validateCreateCustomerEndpointRequest, validateCreateMachineClientRequest, validateCreateMessageRequest, validateMessageCategory, validateMessageCategoryCollection, validateCreateMessageCategoryRequest, validateUpdateMessageCategoryRequest, validateSubscriberCategoryPreference, validateSubscriberCategoryPreferenceCollection, validateSetSubscriberCategoryPreferenceRequest, validateCreateProjectRequest, validateUpdateProjectRequest, validateCreateSubscriptionLinkRequest, validateCustomerEndpoint, validateCustomerEndpointAttemptCollection, validateCustomerEndpointCollection, validateCustomerEndpointMutationResult, validateInteractionSummary, validateMachineClient, validateMachineCredential, validateMachineEventAckRequest, validateMachineEventAckResponse, validateMachineEventPollResponse, validateMessage, validateProblem, validateProject, validateProjectCollection, validateRecipientCopyOverride, validateRecipientCopyOverrideCollection, validateProviderCapabilitiesCollection, validateProviderInstallationCollection, validateEmailDomainCollection, validateCreateEmailDomainRequest, validateRegisterMachineCredentialRequest, validateRotateOrganizationCredentialRequest, validateRotateApiCredentialRequest, validateConnectionTest, validateConnectionTestCollection, validateCreateConnectionTestRequest, validateCustomerApplicationManifest, validateRotateChannelConnectionCredentialRequest, validateRotateCustomerEndpointRequest, validateSubscriptionLink, validateUpdateChannelConnectionRequest, validateUpdateRecipientCopyOverrideRequest, } from "@whooshbang/contracts";
3
+ import { contractValidationErrors, validateOrganizationCredential, validateOrganizationCredentialCollection, validateOrganizationCredentialRotation, validateOrganizationCredentialSecretReveal, validateBillingProjectSlots, validateBillingPromotions, validateBillingPromotion, validateRedeemBillingPromotionRequest, validateAssignBillingProjectSlotsRequest, validateSubscriptionChange, validateConfirmSubscriptionChangeRequest, validateBillingEntitlements, validateSubscriptionSelection, validateProjectAttribution, validateUpdateProjectAttributionRequest, validateAutoTopUpSettings, validateUpdateAutoTopUpSettingsRequest, validateBillingAccount, validateCardSetup, validateCreateCreditPurchaseRequest, validateCreditPurchase, validateBillingInvoiceCollection, validateUpdateBillingReceiptEmailRequest, validateOrganizationProjection, validateApiCredential, validateApiCredentialCollection, validateApiCredentialRotation, validateApiCredentialSecretReveal, validateAttachNotifierConnectionRequest, validateChannelConnection, validateChannelConnectionCollection, validateConnectionProviderCollection, validateUsageReport, validateMessageListPage, validateMessageDeliveryHistory, validateMessageNotificationImage, validateInteractionTimeline, validateUpdateEmailSenderRequest, validateCustomerEventDeliveryHistory, validateCustomerEventDeliveryAttempt, validateDeliveryHolds, validateMachineClientOperationsList, validateRecipientCopyCatalogue, validateNotifierConnectionCollection, validateProjectRecipientExperience, validateRecipientBrandLogoUpload, validateNotificationImageAsset, validateUpdateProjectRecipientExperienceRequest, validateEnvironmentRecipientExperience, validateUpdateEnvironmentRecipientExperienceRequest, validateSubscriberChannelSettings, validateAcknowledgeEmailRemediationRequest, validateCreateRecipientSessionRequest, validateCreateRecipientSessionResponse, validateRecipientSession, validateCreateProviderHandoffRequest, validateProviderHandoff, validateSetPreferredBindingRequest, validatePreferredBinding, validateCreateSubscriberRequest, validateSubscriber, validateSubscriberDataExport, validateUpdateSubscriberRequest, validateSubscriberCollection, validateCloseOrganizationRequest, validateInviteTeammateRequest, validateTeammate, validateTeammateAccessRequest, validateTeammateCollection, validateOrganizationClosureResult, validateCreateSubscriberGroupRequest, validateUpdateSubscriberGroupRequest, validateSubscriberGroup, validateSubscriberGroupCollection, validateSubscriberGroupMembership, validateSubscriberGroupMembershipCollection, validateCreateGroupBroadcastRequest, validateGroupBroadcast, validateCreateOrganizationCredentialRequest, validateCreateApiCredentialRequest, validateCreateChannelConnectionRequest, validateCreateCustomerEndpointRequest, validateCreateMachineClientRequest, validateCreateMessageRequest, validateCancelEscalationByKeyRequest, validateEscalationPathPreview, validateEscalationOrder, validateEscalationOrderCollection, validateSaveEscalationOrderRequest, validateQuietHours, validateSaveQuietHoursRequest, validateSetDigestPreferenceRequest, validateSetSubscriberDigestSettingRequest, validateSubscriberDigestSettings, validateEscalationPolicy, validateEscalationPolicyCollection, validateEscalationLimits, validateUpdateEscalationLimitsRequest, validateEscalationPagingLimitReport, validateUpdateEscalationPolicyRequest, validateCancelEscalationRequest, validateEscalation, validateMessageCategory, validateMessageCategoryCollection, validateCreateMessageCategoryRequest, validateUpdateMessageCategoryRequest, validateSubscriberCategoryPreference, validateSubscriberCategoryPreferenceCollection, validateSetSubscriberCategoryPreferenceRequest, validateCreateProjectRequest, validateUpdateProjectRequest, validateCreateSubscriptionLinkRequest, validateCustomerEndpoint, validateCustomerEndpointAttemptCollection, validateCustomerEndpointCollection, validateCustomerEndpointMutationResult, validateInteractionSummary, validateMachineClient, validateMachineCredential, validateMachineEventAckRequest, validateMachineEventAckResponse, validateMachineEventPollResponse, validateMessage, validateProblem, validateProject, validateProjectCollection, validateRecipientCopyOverride, validateRecipientCopyOverrideCollection, validateProviderCapabilitiesCollection, validateProviderInstallationCollection, validateEmailDomainCollection, validateCreateEmailDomainRequest, validateRegisterMachineCredentialRequest, validateRotateOrganizationCredentialRequest, validateRotateApiCredentialRequest, validateConnectionTest, validateConnectionTestCollection, validateCreateConnectionTestRequest, validateCustomerApplicationManifest, validateRotateChannelConnectionCredentialRequest, validateRotateCustomerEndpointRequest, validateSubscriptionLink, validateUpdateChannelConnectionRequest, validateUpdateRecipientCopyOverrideRequest, } from "@whooshbang/contracts";
4
4
  import { validateAdditiveCompatible } from "./additive-compatibility.js";
5
5
  import { WhooshBangContractError, WhooshBangOutcomeUnknownError, WhooshBangProblemError, WhooshBangProtocolError, WhooshBangTransportError, WhooshBangValidationError, validationError, } from "./errors.js";
6
6
  import { interactionAnswer } from "./interactions.js";
@@ -521,10 +521,16 @@ async function messageCreation(send) {
521
521
  * response; the resource validators alone do not, because the field is an
522
522
  * endpoint-level promise rather than part of the resource.
523
523
  */
524
+ const CANCELLATION_RESPONSE_PATHS = {
525
+ cancelEscalation: "~1v1~1escalations~1{escalation_id}~1cancel",
526
+ cancelEscalationByKey: "~1v1~1escalations~1cancel",
527
+ cancelEscalationByKeyInEnvironment: "~1v1~1projects~1{project_id}~1environments~1{environment_id}~1escalations~1cancel",
528
+ cancelEscalationInEnvironment: "~1v1~1projects~1{project_id}~1environments~1{environment_id}~1escalations~1{escalation_id}~1cancel",
529
+ cancelMessage: "~1v1~1messages~1{message_id}~1cancel",
530
+ cancelSubscriptionLink: "~1v1~1subscription-links~1{subscription_link_id}~1cancel",
531
+ };
524
532
  function cancellationEffectiveMissing(operationId) {
525
- const path = operationId === "cancelMessage"
526
- ? "~1v1~1messages~1{message_id}~1cancel"
527
- : "~1v1~1subscription-links~1{subscription_link_id}~1cancel";
533
+ const path = CANCELLATION_RESPONSE_PATHS[operationId];
528
534
  return {
529
535
  instancePath: "",
530
536
  keyword: "required",
@@ -533,6 +539,16 @@ function cancellationEffectiveMissing(operationId) {
533
539
  schemaPath: `#/paths/${path}/post/responses/200/content/application~1json/schema/allOf/1/required`,
534
540
  };
535
541
  }
542
+ /** Reads a cancellation response's `cancellation_effective` as the outcome. */
543
+ function escalationCancelOutcome(operation, escalation) {
544
+ if (escalation.cancellation_effective === true) {
545
+ return { escalation, outcome: "cancelled" };
546
+ }
547
+ if (escalation.cancellation_effective === false) {
548
+ return { escalation, outcome: "already_closed" };
549
+ }
550
+ throw new WhooshBangContractError(operation, [cancellationEffectiveMissing(operation)], "The cancellation response did not say whether cancellation took effect.");
551
+ }
536
552
  function describeFailure(error) {
537
553
  if (error instanceof WhooshBangProblemError) {
538
554
  return {
@@ -1523,6 +1539,88 @@ export class WhooshBangClient {
1523
1539
  validator: validateSubscriberCategoryPreference,
1524
1540
  });
1525
1541
  }
1542
+ /**
1543
+ * The signed-in teammate's own escalation order for each urgency
1544
+ * (FXO-3673); never another person's.
1545
+ */
1546
+ async getOwnEscalationOrders(projectId, environmentId, options = {}) {
1547
+ const operation = "getOwnEscalationOrders";
1548
+ return this.#request({
1549
+ method: "GET",
1550
+ operation,
1551
+ options,
1552
+ path: `${environmentRoot(operation, projectId, environmentId)}/notification-preferences/escalation-orders`,
1553
+ sideEffect: false,
1554
+ validator: validateEscalationOrderCollection,
1555
+ });
1556
+ }
1557
+ /** Saves the signed-in teammate's own order for one urgency (FXO-3673). */
1558
+ async saveOwnEscalationOrder(projectId, environmentId, level, request, options = {}) {
1559
+ const operation = "saveOwnEscalationOrder";
1560
+ assertInput(operation, request, validateSaveEscalationOrderRequest);
1561
+ return this.#request({
1562
+ body: request,
1563
+ method: "PUT",
1564
+ operation,
1565
+ options,
1566
+ path: `${environmentRoot(operation, projectId, environmentId)}/notification-preferences/escalation-orders/${pathSegment(operation, level, "level")}`,
1567
+ sideEffect: true,
1568
+ validator: validateEscalationOrder,
1569
+ });
1570
+ }
1571
+ /** Returns the signed-in teammate to the project's order for one urgency. */
1572
+ async resetOwnEscalationOrder(projectId, environmentId, level, options = {}) {
1573
+ const operation = "resetOwnEscalationOrder";
1574
+ return this.#request({
1575
+ method: "DELETE",
1576
+ operation,
1577
+ options,
1578
+ path: `${environmentRoot(operation, projectId, environmentId)}/notification-preferences/escalation-orders/${pathSegment(operation, level, "level")}`,
1579
+ sideEffect: true,
1580
+ validator: validateEscalationOrder,
1581
+ });
1582
+ }
1583
+ /** The signed-in teammate's own quiet hours (FXO-2103); never another person's. */
1584
+ async getOwnQuietHours(projectId, environmentId, options = {}) {
1585
+ const operation = "getOwnQuietHours";
1586
+ return this.#request({
1587
+ method: "GET",
1588
+ operation,
1589
+ options,
1590
+ path: `${environmentRoot(operation, projectId, environmentId)}/notification-preferences/quiet-hours`,
1591
+ sideEffect: false,
1592
+ validator: validateQuietHours,
1593
+ });
1594
+ }
1595
+ /**
1596
+ * Replaces the signed-in teammate's own quiet hours. A value outside the
1597
+ * rules fails with `request_invalid` naming the field.
1598
+ */
1599
+ async saveOwnQuietHours(projectId, environmentId, request, options = {}) {
1600
+ const operation = "saveOwnQuietHours";
1601
+ assertInput(operation, request, validateSaveQuietHoursRequest);
1602
+ return this.#request({
1603
+ body: request,
1604
+ method: "PUT",
1605
+ operation,
1606
+ options,
1607
+ path: `${environmentRoot(operation, projectId, environmentId)}/notification-preferences/quiet-hours`,
1608
+ sideEffect: true,
1609
+ validator: validateQuietHours,
1610
+ });
1611
+ }
1612
+ /** Turns off the signed-in teammate's own quiet hours. */
1613
+ async resetOwnQuietHours(projectId, environmentId, options = {}) {
1614
+ const operation = "resetOwnQuietHours";
1615
+ return this.#request({
1616
+ method: "DELETE",
1617
+ operation,
1618
+ options,
1619
+ path: `${environmentRoot(operation, projectId, environmentId)}/notification-preferences/quiet-hours`,
1620
+ sideEffect: true,
1621
+ validator: validateQuietHours,
1622
+ });
1623
+ }
1526
1624
  async getEnvironmentRecipientExperience(projectId, environmentId, options = {}) {
1527
1625
  const operation = "getEnvironmentRecipientExperience";
1528
1626
  return this.#request({
@@ -1559,6 +1657,71 @@ export class WhooshBangClient {
1559
1657
  strictResponse: true,
1560
1658
  });
1561
1659
  }
1660
+ /**
1661
+ * One subscriber's escalation order for every urgency, read only. Only the
1662
+ * subscriber can change it, through their recipient session; unlike the
1663
+ * preferred binding, no application credential can set it.
1664
+ */
1665
+ async getSubscriberEscalationOrders(projectId, environmentId, subscriberId, options = {}) {
1666
+ const operation = "getSubscriberEscalationOrders";
1667
+ return this.#request({
1668
+ method: "GET",
1669
+ operation,
1670
+ options,
1671
+ sideEffect: false,
1672
+ path: `${environmentRoot(operation, projectId, environmentId)}/subscribers/${pathSegment(operation, subscriberId, "subscriberId")}/escalation-orders`,
1673
+ validator: validateEscalationOrderCollection,
1674
+ });
1675
+ }
1676
+ /**
1677
+ * One subscriber's quiet hours, read only. Only the subscriber can change
1678
+ * them, through their recipient session.
1679
+ */
1680
+ async getSubscriberQuietHours(projectId, environmentId, subscriberId, options = {}) {
1681
+ const operation = "getSubscriberQuietHours";
1682
+ return this.#request({
1683
+ method: "GET",
1684
+ operation,
1685
+ options,
1686
+ sideEffect: false,
1687
+ path: `${environmentRoot(operation, projectId, environmentId)}/subscribers/${pathSegment(operation, subscriberId, "subscriberId")}/quiet-hours`,
1688
+ validator: validateQuietHours,
1689
+ });
1690
+ }
1691
+ /**
1692
+ * One subscriber's digest settings: for each category, the policy in
1693
+ * effect, where each setting comes from, what the subscriber may change,
1694
+ * their saved choices and your setting for them (FXO-3729).
1695
+ */
1696
+ async getSubscriberDigestSettings(projectId, environmentId, subscriberId, options = {}) {
1697
+ const operation = "getSubscriberDigestSettings";
1698
+ return this.#request({
1699
+ method: "GET",
1700
+ operation,
1701
+ options,
1702
+ sideEffect: false,
1703
+ path: `${environmentRoot(operation, projectId, environmentId)}/subscribers/${pathSegment(operation, subscriberId, "subscriberId")}/digest-settings`,
1704
+ validator: validateSubscriberDigestSettings,
1705
+ });
1706
+ }
1707
+ /**
1708
+ * Your digest setting for one subscriber and category, and which settings
1709
+ * they can't change; `{ setting: null }` removes it. Their own choice is
1710
+ * kept and returns when you unlock.
1711
+ */
1712
+ async setSubscriberDigestSetting(projectId, environmentId, subscriberId, categoryKey, request, options = {}) {
1713
+ const operation = "setSubscriberDigestSetting";
1714
+ assertInput(operation, request, validateSetSubscriberDigestSettingRequest);
1715
+ return this.#request({
1716
+ body: request,
1717
+ method: "PUT",
1718
+ operation,
1719
+ options,
1720
+ sideEffect: true,
1721
+ path: `${environmentRoot(operation, projectId, environmentId)}/subscribers/${pathSegment(operation, subscriberId, "subscriberId")}/digest-settings/categories/${pathSegment(operation, categoryKey, "categoryKey")}`,
1722
+ validator: validateSubscriberDigestSettings,
1723
+ });
1724
+ }
1562
1725
  async transitionSubscriberBinding(projectId, environmentId, subscriberId, bindingId, action, options = {}) {
1563
1726
  const operation = "transitionSubscriberBinding";
1564
1727
  if (!["pause", "resume", "unsubscribe"].includes(action)) {
@@ -2164,6 +2327,71 @@ export class WhooshBangClient {
2164
2327
  }
2165
2328
  throw new WhooshBangContractError(operation, [cancellationEffectiveMissing("cancelMessage")], "The cancellation response did not say whether cancellation took effect.");
2166
2329
  }
2330
+ /**
2331
+ * Reads an escalation: every stage, each person's attempts and timing, and
2332
+ * the single request-level outcome once it closes.
2333
+ *
2334
+ * While the escalation is open, `wait` holds the read until it closes, up to
2335
+ * 30 seconds; a wait that expires still resolves with the current state.
2336
+ * Inspection changes nothing.
2337
+ */
2338
+ async getEscalation(escalationId, options = {}) {
2339
+ const operation = "getEscalation";
2340
+ const suffix = inspectionWait(operation, options.wait);
2341
+ return this.#request({
2342
+ method: "GET",
2343
+ operation,
2344
+ options,
2345
+ path: `v1/escalations/${pathSegment(operation, escalationId, "escalationId")}${suffix}`,
2346
+ sideEffect: false,
2347
+ validator: validateEscalation,
2348
+ });
2349
+ }
2350
+ /**
2351
+ * Stops every future attempt of an escalation and reports whether this call
2352
+ * closed it.
2353
+ *
2354
+ * Idempotent on the service: cancelling a closed escalation, including one
2355
+ * already answered, returns it unchanged as `already_closed`. Pass
2356
+ * `reason: "resolved"` when your application resolved the matter itself.
2357
+ */
2358
+ async cancelEscalation(escalationId, request = {}, options = {}) {
2359
+ const operation = "cancelEscalation";
2360
+ assertInput(operation, request, validateCancelEscalationRequest);
2361
+ const escalation = await this.#request({
2362
+ body: request,
2363
+ method: "POST",
2364
+ operation,
2365
+ options,
2366
+ path: `v1/escalations/${pathSegment(operation, escalationId, "escalationId")}/cancel`,
2367
+ sideEffect: true,
2368
+ validator: validateEscalation,
2369
+ });
2370
+ return escalationCancelOutcome(operation, escalation);
2371
+ }
2372
+ /**
2373
+ * Cancels the escalation created by the send that used this idempotency
2374
+ * key, for a caller that kept the key but not the escalation id.
2375
+ *
2376
+ * `send_operation` names the send that used the key: `createMessage` (the
2377
+ * default, covering `createMessageInEnvironment` too) or
2378
+ * `sendOperatorMessage`. A key whose send did not escalate, or that matches
2379
+ * nothing, is `resource_not_found`.
2380
+ */
2381
+ async cancelEscalationByKey(request, options = {}) {
2382
+ const operation = "cancelEscalationByKey";
2383
+ assertInput(operation, request, validateCancelEscalationByKeyRequest);
2384
+ const escalation = await this.#request({
2385
+ body: request,
2386
+ method: "POST",
2387
+ operation,
2388
+ options,
2389
+ path: "v1/escalations/cancel",
2390
+ sideEffect: true,
2391
+ validator: validateEscalation,
2392
+ });
2393
+ return escalationCancelOutcome(operation, escalation);
2394
+ }
2167
2395
  async getCapabilities(options = {}) {
2168
2396
  return this.#request({
2169
2397
  method: "GET",
@@ -3044,6 +3272,161 @@ export class WhooshBangClient {
3044
3272
  validator: validateInteractionSummary,
3045
3273
  });
3046
3274
  }
3275
+ async getEscalationInEnvironment(projectId, environmentId, escalationId, options = {}) {
3276
+ const operation = "getEscalationInEnvironment";
3277
+ const suffix = inspectionWait(operation, options.wait);
3278
+ return this.#request({
3279
+ method: "GET",
3280
+ operation,
3281
+ options,
3282
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalations/` +
3283
+ `${pathSegment(operation, escalationId, "escalationId")}${suffix}`,
3284
+ sideEffect: false,
3285
+ validator: validateEscalation,
3286
+ });
3287
+ }
3288
+ async cancelEscalationInEnvironment(projectId, environmentId, escalationId, request = {}, options = {}) {
3289
+ const operation = "cancelEscalationInEnvironment";
3290
+ assertInput(operation, request, validateCancelEscalationRequest);
3291
+ const escalation = await this.#request({
3292
+ body: request,
3293
+ method: "POST",
3294
+ operation,
3295
+ options,
3296
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalations/` +
3297
+ `${pathSegment(operation, escalationId, "escalationId")}/cancel`,
3298
+ sideEffect: true,
3299
+ validator: validateEscalation,
3300
+ });
3301
+ return escalationCancelOutcome(operation, escalation);
3302
+ }
3303
+ async cancelEscalationByKeyInEnvironment(projectId, environmentId, request, options = {}) {
3304
+ const operation = "cancelEscalationByKeyInEnvironment";
3305
+ assertInput(operation, request, validateCancelEscalationByKeyRequest);
3306
+ const escalation = await this.#request({
3307
+ body: request,
3308
+ method: "POST",
3309
+ operation,
3310
+ options,
3311
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalations/cancel`,
3312
+ sideEffect: true,
3313
+ validator: validateEscalation,
3314
+ });
3315
+ return escalationCancelOutcome(operation, escalation);
3316
+ }
3317
+ /**
3318
+ * The environment's escalation limits and the most each may be
3319
+ * (FXO-2105). Until someone narrows them every limit is its maximum and
3320
+ * `version` is absent.
3321
+ */
3322
+ async getEscalationLimits(projectId, environmentId, options = {}) {
3323
+ const operation = "getEscalationLimits";
3324
+ return this.#request({
3325
+ method: "GET",
3326
+ operation,
3327
+ options,
3328
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalation-limits`,
3329
+ sideEffect: false,
3330
+ validator: validateEscalationLimits,
3331
+ });
3332
+ }
3333
+ /**
3334
+ * Narrows the environment's escalation limits. Send the `version` read,
3335
+ * or omit it when none was shown; a stale one fails with
3336
+ * `escalation_limits_conflict` and nothing changes.
3337
+ */
3338
+ async updateEscalationLimits(projectId, environmentId, request, options = {}) {
3339
+ const operation = "updateEscalationLimits";
3340
+ assertInput(operation, request, validateUpdateEscalationLimitsRequest);
3341
+ return this.#request({
3342
+ body: request,
3343
+ method: "PUT",
3344
+ operation,
3345
+ options,
3346
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalation-limits`,
3347
+ sideEffect: true,
3348
+ validator: validateEscalationLimits,
3349
+ });
3350
+ }
3351
+ /** What the paging limit held back in this environment over the last 7 days. */
3352
+ async getEscalationPagingLimitReport(projectId, environmentId, options = {}) {
3353
+ const operation = "getEscalationPagingLimitReport";
3354
+ return this.#request({
3355
+ method: "GET",
3356
+ operation,
3357
+ options,
3358
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalation-limits/held-back`,
3359
+ sideEffect: false,
3360
+ validator: validateEscalationPagingLimitReport,
3361
+ });
3362
+ }
3363
+ /** One escalation default per urgency tier, lowest first (FXO-2103). */
3364
+ async listEscalationPolicies(projectId, environmentId, options = {}) {
3365
+ const operation = "listEscalationPolicies";
3366
+ return this.#request({
3367
+ method: "GET",
3368
+ operation,
3369
+ options,
3370
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalation-policies`,
3371
+ sideEffect: false,
3372
+ validator: validateEscalationPolicyCollection,
3373
+ });
3374
+ }
3375
+ /** A tier's saved default, or the built-in suggested order. */
3376
+ async getEscalationPolicy(projectId, environmentId, level, options = {}) {
3377
+ const operation = "getEscalationPolicy";
3378
+ return this.#request({
3379
+ method: "GET",
3380
+ operation,
3381
+ options,
3382
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalation-policies/${pathSegment(operation, level, "level")}`,
3383
+ sideEffect: false,
3384
+ validator: validateEscalationPolicy,
3385
+ });
3386
+ }
3387
+ /**
3388
+ * Saves a tier's default as a new version. Every step's channel must be
3389
+ * connected in the environment, or the call fails with
3390
+ * `escalation_policy_channel_unconnected` and nothing changes.
3391
+ */
3392
+ async updateEscalationPolicy(projectId, environmentId, level, request, options = {}) {
3393
+ const operation = "updateEscalationPolicy";
3394
+ assertInput(operation, request, validateUpdateEscalationPolicyRequest);
3395
+ return this.#request({
3396
+ body: request,
3397
+ method: "PUT",
3398
+ operation,
3399
+ options,
3400
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalation-policies/${pathSegment(operation, level, "level")}`,
3401
+ sideEffect: true,
3402
+ validator: validateEscalationPolicy,
3403
+ });
3404
+ }
3405
+ /** Returns a tier to the built-in suggested order and returns that order. */
3406
+ async resetEscalationPolicy(projectId, environmentId, level, options = {}) {
3407
+ const operation = "resetEscalationPolicy";
3408
+ return this.#request({
3409
+ method: "DELETE",
3410
+ operation,
3411
+ options,
3412
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalation-policies/${pathSegment(operation, level, "level")}`,
3413
+ sideEffect: true,
3414
+ validator: validateEscalationPolicy,
3415
+ });
3416
+ }
3417
+ /** The order an escalation at this tier would snapshot for one subscriber. */
3418
+ async previewEscalationPath(projectId, environmentId, level, subscriberId, options = {}) {
3419
+ const operation = "previewEscalationPath";
3420
+ const query = new URLSearchParams({ subscriber_id: subscriberId });
3421
+ return this.#request({
3422
+ method: "GET",
3423
+ operation,
3424
+ options,
3425
+ path: `${environmentRoot(operation, projectId, environmentId)}/escalation-policies/${pathSegment(operation, level, "level")}/preview?${query}`,
3426
+ sideEffect: false,
3427
+ validator: validateEscalationPathPreview,
3428
+ });
3429
+ }
3047
3430
  async createMachineClientInEnvironment(projectId, environmentId, request, options = {}) {
3048
3431
  const operation = "createMachineClientInEnvironment";
3049
3432
  assertInput(operation, request, validateCreateMachineClientRequest);
@@ -3637,6 +4020,153 @@ export class WhooshBangRecipientSessionClient {
3637
4020
  validator: validatePreferredBinding,
3638
4021
  });
3639
4022
  }
4023
+ /**
4024
+ * This subscriber's escalation order for every urgency: their own where they
4025
+ * saved one, otherwise the project's, with each step's availability and the
4026
+ * eligible bindings the order leaves out.
4027
+ */
4028
+ async getEscalationOrders(options = {}) {
4029
+ const operation = "getEscalationOrders";
4030
+ return this.#request({
4031
+ method: "GET",
4032
+ operation,
4033
+ options,
4034
+ path: "v1/recipient-session/escalation-orders",
4035
+ sideEffect: false,
4036
+ validator: validateEscalationOrderCollection,
4037
+ });
4038
+ }
4039
+ /**
4040
+ * Saves this subscriber's own order for one urgency. An empty `steps` is a
4041
+ * choice that nothing is tried. Send back the `version` the tier showed
4042
+ * when read (none for the suggested order); an order that changed since
4043
+ * fails with `escalation_order_conflict`, and a binding they cannot use
4044
+ * with `escalation_order_step_ineligible`.
4045
+ */
4046
+ async saveEscalationOrder(level, request, options = {}) {
4047
+ const operation = "saveEscalationOrder";
4048
+ assertInput(operation, request, validateSaveEscalationOrderRequest);
4049
+ return this.#request({
4050
+ body: request,
4051
+ method: "PUT",
4052
+ operation,
4053
+ options,
4054
+ path: `v1/recipient-session/escalation-orders/${pathSegment(operation, level, "level")}`,
4055
+ sideEffect: true,
4056
+ validator: validateEscalationOrder,
4057
+ });
4058
+ }
4059
+ /** Goes back to the project's order for one urgency. */
4060
+ async resetEscalationOrder(level, options = {}) {
4061
+ const operation = "resetEscalationOrder";
4062
+ return this.#request({
4063
+ method: "DELETE",
4064
+ operation,
4065
+ options,
4066
+ path: `v1/recipient-session/escalation-orders/${pathSegment(operation, level, "level")}`,
4067
+ sideEffect: true,
4068
+ validator: validateEscalationOrder,
4069
+ });
4070
+ }
4071
+ /**
4072
+ * This subscriber's quiet hours: when they would rather not be interrupted,
4073
+ * what each channel does then, the choices each channel offers, the
4074
+ * channels a withheld message can go to, and whether quiet hours are on now.
4075
+ */
4076
+ async getQuietHours(options = {}) {
4077
+ const operation = "getQuietHours";
4078
+ return this.#request({
4079
+ method: "GET",
4080
+ operation,
4081
+ options,
4082
+ path: "v1/recipient-session/quiet-hours",
4083
+ sideEffect: false,
4084
+ validator: validateQuietHours,
4085
+ });
4086
+ }
4087
+ /**
4088
+ * Replaces this subscriber's quiet hours. Send the time zone they see the
4089
+ * times in. A value outside the rules fails with `request_invalid` naming
4090
+ * the field, such as `quiet_channel_unavailable` for a quiet channel that
4091
+ * is not theirs.
4092
+ */
4093
+ async saveQuietHours(request, options = {}) {
4094
+ const operation = "saveQuietHours";
4095
+ assertInput(operation, request, validateSaveQuietHoursRequest);
4096
+ return this.#request({
4097
+ body: request,
4098
+ method: "PUT",
4099
+ operation,
4100
+ options,
4101
+ path: "v1/recipient-session/quiet-hours",
4102
+ sideEffect: true,
4103
+ validator: validateQuietHours,
4104
+ });
4105
+ }
4106
+ /**
4107
+ * This subscriber's digest settings: only the categories whose owner lets
4108
+ * them choose something, with what is in effect and what they can change,
4109
+ * plus their Default (FXO-3729).
4110
+ */
4111
+ async getDigestSettings(options = {}) {
4112
+ const operation = "getDigestSettings";
4113
+ return this.#request({
4114
+ method: "GET",
4115
+ operation,
4116
+ options,
4117
+ path: "v1/recipient-session/digest-settings",
4118
+ sideEffect: false,
4119
+ validator: validateSubscriberDigestSettings,
4120
+ });
4121
+ }
4122
+ /**
4123
+ * Sets this subscriber's Default digest choice, or clears it with
4124
+ * `{ preference: null }`. A setting the owner doesn't offer fails with
4125
+ * `request_invalid` naming it, and the previous setting stays.
4126
+ */
4127
+ async setDefaultDigestPreference(request, options = {}) {
4128
+ const operation = "setDefaultDigestPreference";
4129
+ assertInput(operation, request, validateSetDigestPreferenceRequest);
4130
+ return this.#request({
4131
+ body: request,
4132
+ method: "PUT",
4133
+ operation,
4134
+ options,
4135
+ path: "v1/recipient-session/digest-settings/default",
4136
+ sideEffect: true,
4137
+ validator: validateSubscriberDigestSettings,
4138
+ });
4139
+ }
4140
+ /**
4141
+ * Sets this subscriber's digest choice for one category, or clears it so
4142
+ * the category follows the Default again. Locked or unoffered settings
4143
+ * fail with `request_invalid` and the previous setting stays.
4144
+ */
4145
+ async setCategoryDigestPreference(categoryKey, request, options = {}) {
4146
+ const operation = "setCategoryDigestPreference";
4147
+ assertInput(operation, request, validateSetDigestPreferenceRequest);
4148
+ return this.#request({
4149
+ body: request,
4150
+ method: "PUT",
4151
+ operation,
4152
+ options,
4153
+ path: `v1/recipient-session/digest-settings/categories/${pathSegment(operation, categoryKey, "categoryKey")}`,
4154
+ sideEffect: true,
4155
+ validator: validateSubscriberDigestSettings,
4156
+ });
4157
+ }
4158
+ /** Turns off this subscriber's quiet hours. */
4159
+ async resetQuietHours(options = {}) {
4160
+ const operation = "resetQuietHours";
4161
+ return this.#request({
4162
+ method: "DELETE",
4163
+ operation,
4164
+ options,
4165
+ path: "v1/recipient-session/quiet-hours",
4166
+ sideEffect: true,
4167
+ validator: validateQuietHours,
4168
+ });
4169
+ }
3640
4170
  async transitionBinding(bindingId, action, options = {}) {
3641
4171
  const operation = `${action}RecipientBinding`;
3642
4172
  return this.#request({