@trycourier/courier 6.3.1 → 6.4.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/Client.d.ts +84 -109
- package/Client.js +118 -148
- package/api/client/requests/SendMessageRequest.d.ts +45 -78
- package/api/resources/audiences/client/Client.d.ts +16 -16
- package/api/resources/audiences/client/Client.js +63 -86
- package/api/resources/audiences/client/requests/AudienceMembersListParams.d.ts +1 -3
- package/api/resources/audiences/client/requests/AudienceUpdateParams.d.ts +3 -7
- package/api/resources/audiences/client/requests/AudiencesListParams.d.ts +1 -3
- package/api/resources/audiences/types/ComparisonOperator.d.ts +1 -1
- package/api/resources/audiences/types/Filter.d.ts +1 -1
- package/api/resources/audiences/types/FilterConfig.d.ts +1 -1
- package/api/resources/audiences/types/LogicalOperator.d.ts +1 -1
- package/api/resources/audiences/types/Operator.d.ts +1 -1
- package/api/resources/auditEvents/client/Client.d.ts +10 -4
- package/api/resources/auditEvents/client/Client.js +35 -37
- package/api/resources/auditEvents/client/requests/ListAuditEventsRequest.d.ts +1 -3
- package/api/resources/authTokens/client/Client.d.ts +11 -3
- package/api/resources/authTokens/client/Client.js +28 -25
- package/api/resources/authTokens/client/requests/IssueTokenParams.d.ts +2 -2
- package/api/resources/automations/client/Client.d.ts +15 -13
- package/api/resources/automations/client/Client.js +38 -48
- package/api/resources/automations/types/AutomationAddToBatchMaxItemsType.d.ts +1 -1
- package/api/resources/automations/types/AutomationAddToBatchRetainType.d.ts +1 -1
- package/api/resources/automations/types/AutomationAddToBatchScope.d.ts +1 -1
- package/api/resources/automations/types/AutomationFetchDataWebhookMethod.d.ts +1 -1
- package/api/resources/automations/types/AutomationStepOption.d.ts +1 -1
- package/api/resources/automations/types/AutomationThrottleScope.d.ts +1 -1
- package/api/resources/automations/types/MergeAlgorithm.d.ts +1 -1
- package/api/resources/automations/types/Profile.d.ts +1 -1
- package/api/resources/brands/client/Client.d.ts +22 -58
- package/api/resources/brands/client/Client.js +65 -126
- package/api/resources/brands/client/requests/BrandUpdateParameters.d.ts +3 -26
- package/api/resources/brands/client/requests/ListBrandsRequest.d.ts +1 -3
- package/api/resources/bulk/client/Client.d.ts +30 -121
- package/api/resources/bulk/client/Client.js +73 -193
- package/api/resources/bulk/client/requests/BulkCreateJobParams.d.ts +6 -86
- package/api/resources/bulk/client/requests/BulkGetUsersParams.d.ts +1 -3
- package/api/resources/bulk/types/BulkJobStatus.d.ts +1 -1
- package/api/resources/bulk/types/BulkJobUserStatus.d.ts +1 -1
- package/api/resources/bulk/types/InboundBulkMessageV2.d.ts +3 -5
- package/api/resources/commons/errors/AlreadyExistsError.js +17 -7
- package/api/resources/commons/errors/BadRequestError.js +17 -7
- package/api/resources/commons/errors/ConflictError.js +17 -7
- package/api/resources/commons/errors/MessageNotFoundError.js +17 -7
- package/api/resources/commons/errors/NotFoundError.js +17 -7
- package/api/resources/commons/errors/PaymentRequiredError.js +17 -7
- package/api/resources/commons/types/ChannelClassification.d.ts +1 -1
- package/api/resources/commons/types/NotificationPreferences.d.ts +1 -1
- package/api/resources/commons/types/PreferenceStatus.d.ts +1 -1
- package/api/resources/inbound/client/Client.d.ts +9 -1
- package/api/resources/inbound/client/Client.js +26 -21
- package/api/resources/index.js +17 -7
- package/api/resources/lists/client/Client.d.ts +31 -34
- package/api/resources/lists/client/Client.js +108 -161
- package/api/resources/lists/client/requests/AddSubscribersToList.d.ts +5 -5
- package/api/resources/lists/client/requests/GetAllListsRequest.d.ts +1 -4
- package/api/resources/lists/client/requests/GetSubscriptionForListRequest.d.ts +1 -3
- package/api/resources/lists/client/requests/SubscribeUserToListRequest.d.ts +1 -4
- package/api/resources/lists/client/requests/SubscribeUsersToListRequest.d.ts +5 -5
- package/api/resources/messages/client/Client.d.ts +15 -24
- package/api/resources/messages/client/Client.js +65 -104
- package/api/resources/messages/client/requests/GetMessageHistoryRequest.d.ts +1 -3
- package/api/resources/messages/client/requests/ListMessagesRequest.d.ts +1 -16
- package/api/resources/messages/types/MessageDetailsExtended.d.ts +7 -0
- package/api/resources/messages/types/MessageDetailsExtended.js +5 -0
- package/api/resources/messages/types/MessageStatus.d.ts +25 -5
- package/api/resources/messages/types/MessageStatus.js +6 -1
- package/api/resources/messages/types/Reason.d.ts +1 -1
- package/api/resources/messages/types/index.d.ts +1 -0
- package/api/resources/messages/types/index.js +1 -0
- package/api/resources/notifications/client/Client.d.ts +20 -11
- package/api/resources/notifications/client/Client.js +69 -88
- package/api/resources/notifications/client/requests/NotificationListParams.d.ts +1 -4
- package/api/resources/notifications/client/requests/SubmissionChecksReplaceParams.d.ts +6 -2
- package/api/resources/notifications/types/BlockType.d.ts +1 -1
- package/api/resources/notifications/types/CheckStatus.d.ts +1 -1
- package/api/resources/notifications/types/MessageRoutingChannel.d.ts +1 -1
- package/api/resources/notifications/types/MessageRoutingMethod.d.ts +1 -1
- package/api/resources/notifications/types/NotificationContent.d.ts +1 -1
- package/api/resources/profiles/client/Client.d.ts +35 -23
- package/api/resources/profiles/client/Client.js +95 -125
- package/api/resources/profiles/client/requests/GetListSubscriptionsRequest.d.ts +1 -3
- package/api/resources/profiles/client/requests/MergeProfileRequest.d.ts +1 -1
- package/api/resources/profiles/client/requests/ReplaceProfileRequest.d.ts +1 -1
- package/api/resources/profiles/types/DeviceType.d.ts +1 -1
- package/api/resources/profiles/types/Discord.d.ts +1 -1
- package/api/resources/profiles/types/Expo.d.ts +1 -1
- package/api/resources/profiles/types/MsTeams.d.ts +1 -1
- package/api/resources/profiles/types/ProfileUpdateRequest.d.ts +8 -0
- package/api/resources/profiles/types/ProfileUpdateRequest.js +5 -0
- package/api/resources/profiles/types/Slack.d.ts +1 -1
- package/api/resources/profiles/types/SnoozeRuleType.d.ts +1 -1
- package/api/resources/profiles/types/UserProfileFirebaseToken.d.ts +1 -1
- package/api/resources/profiles/types/WebhookAuthMode.d.ts +1 -1
- package/api/resources/profiles/types/WebhookMethod.d.ts +1 -1
- package/api/resources/profiles/types/WebhookProfileType.d.ts +1 -1
- package/api/resources/profiles/types/index.d.ts +1 -0
- package/api/resources/profiles/types/index.js +1 -0
- package/api/resources/send/types/Attachment.d.ts +1 -1
- package/api/resources/send/types/ChannelSource.d.ts +1 -1
- package/api/resources/send/types/Content.d.ts +1 -1
- package/api/resources/send/types/Criteria.d.ts +1 -1
- package/api/resources/send/types/ElementalNode.d.ts +1 -1
- package/api/resources/send/types/ExpiresInType.d.ts +1 -1
- package/api/resources/send/types/IActionButtonStyle.d.ts +1 -1
- package/api/resources/send/types/IAlignment.d.ts +1 -1
- package/api/resources/send/types/IPreferences.d.ts +1 -1
- package/api/resources/send/types/InAppPlacement.d.ts +1 -1
- package/api/resources/send/types/Locales.d.ts +1 -1
- package/api/resources/send/types/Message.d.ts +1 -1
- package/api/resources/send/types/MessageChannels.d.ts +1 -1
- package/api/resources/send/types/MessageData.d.ts +1 -1
- package/api/resources/send/types/MessageProviders.d.ts +1 -1
- package/api/resources/send/types/MessageRecipient.d.ts +1 -1
- package/api/resources/send/types/Recipient.d.ts +1 -1
- package/api/resources/send/types/RecipientData.d.ts +1 -1
- package/api/resources/send/types/RoutingChannel.d.ts +1 -1
- package/api/resources/send/types/RoutingMethod.d.ts +1 -1
- package/api/resources/send/types/RuleType.d.ts +1 -1
- package/api/resources/send/types/TextAlign.d.ts +1 -1
- package/api/resources/send/types/TextStyle.d.ts +1 -1
- package/api/resources/templates/client/Client.d.ts +9 -3
- package/api/resources/templates/client/Client.js +28 -25
- package/api/resources/templates/client/requests/ListTemplatesRequest.d.ts +1 -3
- package/api/resources/templates/types/ChannelIdentifier.d.ts +1 -1
- package/api/resources/templates/types/RoutingStrategyMethod.d.ts +1 -1
- package/api/resources/tenants/client/Client.d.ts +23 -37
- package/api/resources/tenants/client/Client.js +80 -127
- package/api/resources/tenants/client/requests/ListTenantParams.d.ts +1 -5
- package/api/resources/tenants/client/requests/ListUsersForTenantParams.d.ts +1 -4
- package/api/resources/tenants/client/requests/TenantCreateOrReplaceParams.d.ts +6 -21
- package/api/resources/tenants/types/SubscriptionTopicStatus.d.ts +1 -1
- package/api/resources/tenants/types/TemplateProperty.d.ts +1 -1
- package/api/resources/translations/client/Client.d.ts +10 -2
- package/api/resources/translations/client/Client.js +33 -33
- package/api/resources/users/client/Client.d.ts +5 -7
- package/api/resources/users/resources/index.js +17 -7
- package/api/resources/users/resources/preferences/client/Client.d.ts +13 -9
- package/api/resources/users/resources/preferences/client/Client.js +46 -55
- package/api/resources/users/resources/preferences/client/requests/UserPreferencesParams.d.ts +1 -3
- package/api/resources/users/resources/preferences/client/requests/UserPreferencesTopicParams.d.ts +1 -3
- package/api/resources/users/resources/preferences/client/requests/UserPreferencesUpdateParams.d.ts +2 -2
- package/api/resources/users/resources/tenants/client/Client.d.ts +23 -21
- package/api/resources/users/resources/tenants/client/Client.js +68 -89
- package/api/resources/users/resources/tenants/client/requests/AddUserToMultipleTenantsParams.d.ts +9 -8
- package/api/resources/users/resources/tenants/client/requests/AddUserToSingleTenantsParams.d.ts +1 -5
- package/api/resources/users/resources/tenants/client/requests/ListTenantsForUserParams.d.ts +1 -4
- package/api/resources/users/resources/tokens/client/Client.d.ts +27 -29
- package/api/resources/users/resources/tokens/client/Client.js +74 -104
- package/api/resources/users/resources/tokens/types/ExpiryDate.d.ts +1 -1
- package/api/resources/users/resources/tokens/types/GetAllTokensResponse.d.ts +1 -1
- package/api/resources/users/resources/tokens/types/PatchOp.d.ts +1 -1
- package/api/resources/users/resources/tokens/types/ProviderKey.d.ts +1 -1
- package/api/resources/users/resources/tokens/types/TokenStatus.d.ts +1 -1
- package/core/auth/BearerToken.d.ts +1 -1
- package/core/fetcher/APIResponse.d.ts +1 -1
- package/core/fetcher/Fetcher.d.ts +7 -3
- package/core/fetcher/Fetcher.js +30 -135
- package/core/fetcher/Supplier.d.ts +1 -1
- package/core/fetcher/createRequestUrl.d.ts +1 -0
- package/core/fetcher/createRequestUrl.js +12 -0
- package/core/fetcher/getFetchFn.d.ts +4 -0
- package/core/fetcher/getFetchFn.js +68 -0
- package/core/fetcher/getHeader.js +1 -2
- package/core/fetcher/getRequestBody.d.ts +7 -0
- package/core/fetcher/getRequestBody.js +23 -0
- package/core/fetcher/getResponseBody.d.ts +1 -0
- package/core/fetcher/getResponseBody.js +54 -0
- package/core/fetcher/makeRequest.d.ts +1 -0
- package/core/fetcher/makeRequest.js +42 -0
- package/core/fetcher/requestWithRetries.d.ts +1 -0
- package/core/fetcher/requestWithRetries.js +40 -0
- package/core/fetcher/signals.d.ts +11 -0
- package/core/fetcher/signals.js +36 -0
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +126 -0
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +59 -0
- package/core/json.d.ts +15 -0
- package/core/json.js +24 -0
- package/core/runtime/runtime.d.ts +2 -1
- package/core/runtime/runtime.js +57 -36
- package/dist/Client.d.ts +84 -109
- package/dist/Client.js +118 -148
- package/dist/api/client/requests/SendMessageRequest.d.ts +45 -78
- package/dist/api/resources/audiences/client/Client.d.ts +16 -16
- package/dist/api/resources/audiences/client/Client.js +63 -86
- package/dist/api/resources/audiences/client/requests/AudienceMembersListParams.d.ts +1 -3
- package/dist/api/resources/audiences/client/requests/AudienceUpdateParams.d.ts +3 -7
- package/dist/api/resources/audiences/client/requests/AudiencesListParams.d.ts +1 -3
- package/dist/api/resources/audiences/types/ComparisonOperator.d.ts +1 -1
- package/dist/api/resources/audiences/types/Filter.d.ts +1 -1
- package/dist/api/resources/audiences/types/FilterConfig.d.ts +1 -1
- package/dist/api/resources/audiences/types/LogicalOperator.d.ts +1 -1
- package/dist/api/resources/audiences/types/Operator.d.ts +1 -1
- package/dist/api/resources/auditEvents/client/Client.d.ts +10 -4
- package/dist/api/resources/auditEvents/client/Client.js +35 -37
- package/dist/api/resources/auditEvents/client/requests/ListAuditEventsRequest.d.ts +1 -3
- package/dist/api/resources/authTokens/client/Client.d.ts +11 -3
- package/dist/api/resources/authTokens/client/Client.js +28 -25
- package/dist/api/resources/authTokens/client/requests/IssueTokenParams.d.ts +2 -2
- package/dist/api/resources/automations/client/Client.d.ts +15 -13
- package/dist/api/resources/automations/client/Client.js +38 -48
- package/dist/api/resources/automations/types/AutomationAddToBatchMaxItemsType.d.ts +1 -1
- package/dist/api/resources/automations/types/AutomationAddToBatchRetainType.d.ts +1 -1
- package/dist/api/resources/automations/types/AutomationAddToBatchScope.d.ts +1 -1
- package/dist/api/resources/automations/types/AutomationFetchDataWebhookMethod.d.ts +1 -1
- package/dist/api/resources/automations/types/AutomationStepOption.d.ts +1 -1
- package/dist/api/resources/automations/types/AutomationThrottleScope.d.ts +1 -1
- package/dist/api/resources/automations/types/MergeAlgorithm.d.ts +1 -1
- package/dist/api/resources/automations/types/Profile.d.ts +1 -1
- package/dist/api/resources/brands/client/Client.d.ts +22 -58
- package/dist/api/resources/brands/client/Client.js +65 -126
- package/dist/api/resources/brands/client/requests/BrandUpdateParameters.d.ts +3 -26
- package/dist/api/resources/brands/client/requests/ListBrandsRequest.d.ts +1 -3
- package/dist/api/resources/bulk/client/Client.d.ts +30 -121
- package/dist/api/resources/bulk/client/Client.js +73 -193
- package/dist/api/resources/bulk/client/requests/BulkCreateJobParams.d.ts +6 -86
- package/dist/api/resources/bulk/client/requests/BulkGetUsersParams.d.ts +1 -3
- package/dist/api/resources/bulk/types/BulkJobStatus.d.ts +1 -1
- package/dist/api/resources/bulk/types/BulkJobUserStatus.d.ts +1 -1
- package/dist/api/resources/bulk/types/InboundBulkMessageV2.d.ts +3 -5
- package/dist/api/resources/commons/errors/AlreadyExistsError.js +17 -7
- package/dist/api/resources/commons/errors/BadRequestError.js +17 -7
- package/dist/api/resources/commons/errors/ConflictError.js +17 -7
- package/dist/api/resources/commons/errors/MessageNotFoundError.js +17 -7
- package/dist/api/resources/commons/errors/NotFoundError.js +17 -7
- package/dist/api/resources/commons/errors/PaymentRequiredError.js +17 -7
- package/dist/api/resources/commons/types/ChannelClassification.d.ts +1 -1
- package/dist/api/resources/commons/types/NotificationPreferences.d.ts +1 -1
- package/dist/api/resources/commons/types/PreferenceStatus.d.ts +1 -1
- package/dist/api/resources/inbound/client/Client.d.ts +9 -1
- package/dist/api/resources/inbound/client/Client.js +26 -21
- package/dist/api/resources/index.js +17 -7
- package/dist/api/resources/lists/client/Client.d.ts +31 -34
- package/dist/api/resources/lists/client/Client.js +108 -161
- package/dist/api/resources/lists/client/requests/AddSubscribersToList.d.ts +5 -5
- package/dist/api/resources/lists/client/requests/GetAllListsRequest.d.ts +1 -4
- package/dist/api/resources/lists/client/requests/GetSubscriptionForListRequest.d.ts +1 -3
- package/dist/api/resources/lists/client/requests/SubscribeUserToListRequest.d.ts +1 -4
- package/dist/api/resources/lists/client/requests/SubscribeUsersToListRequest.d.ts +5 -5
- package/dist/api/resources/messages/client/Client.d.ts +15 -24
- package/dist/api/resources/messages/client/Client.js +65 -104
- package/dist/api/resources/messages/client/requests/GetMessageHistoryRequest.d.ts +1 -3
- package/dist/api/resources/messages/client/requests/ListMessagesRequest.d.ts +1 -16
- package/dist/api/resources/messages/types/MessageDetailsExtended.d.ts +7 -0
- package/dist/api/resources/messages/types/MessageDetailsExtended.js +5 -0
- package/dist/api/resources/messages/types/MessageStatus.d.ts +25 -5
- package/dist/api/resources/messages/types/MessageStatus.js +6 -1
- package/dist/api/resources/messages/types/Reason.d.ts +1 -1
- package/dist/api/resources/messages/types/index.d.ts +1 -0
- package/dist/api/resources/messages/types/index.js +1 -0
- package/dist/api/resources/notifications/client/Client.d.ts +20 -11
- package/dist/api/resources/notifications/client/Client.js +69 -88
- package/dist/api/resources/notifications/client/requests/NotificationListParams.d.ts +1 -4
- package/dist/api/resources/notifications/client/requests/SubmissionChecksReplaceParams.d.ts +6 -2
- package/dist/api/resources/notifications/types/BlockType.d.ts +1 -1
- package/dist/api/resources/notifications/types/CheckStatus.d.ts +1 -1
- package/dist/api/resources/notifications/types/MessageRoutingChannel.d.ts +1 -1
- package/dist/api/resources/notifications/types/MessageRoutingMethod.d.ts +1 -1
- package/dist/api/resources/notifications/types/NotificationContent.d.ts +1 -1
- package/dist/api/resources/profiles/client/Client.d.ts +35 -23
- package/dist/api/resources/profiles/client/Client.js +95 -125
- package/dist/api/resources/profiles/client/requests/GetListSubscriptionsRequest.d.ts +1 -3
- package/dist/api/resources/profiles/client/requests/MergeProfileRequest.d.ts +1 -1
- package/dist/api/resources/profiles/client/requests/ReplaceProfileRequest.d.ts +1 -1
- package/dist/api/resources/profiles/types/DeviceType.d.ts +1 -1
- package/dist/api/resources/profiles/types/Discord.d.ts +1 -1
- package/dist/api/resources/profiles/types/Expo.d.ts +1 -1
- package/dist/api/resources/profiles/types/MsTeams.d.ts +1 -1
- package/dist/api/resources/profiles/types/ProfileUpdateRequest.d.ts +8 -0
- package/dist/api/resources/profiles/types/ProfileUpdateRequest.js +5 -0
- package/dist/api/resources/profiles/types/Slack.d.ts +1 -1
- package/dist/api/resources/profiles/types/SnoozeRuleType.d.ts +1 -1
- package/dist/api/resources/profiles/types/UserProfileFirebaseToken.d.ts +1 -1
- package/dist/api/resources/profiles/types/WebhookAuthMode.d.ts +1 -1
- package/dist/api/resources/profiles/types/WebhookMethod.d.ts +1 -1
- package/dist/api/resources/profiles/types/WebhookProfileType.d.ts +1 -1
- package/dist/api/resources/profiles/types/index.d.ts +1 -0
- package/dist/api/resources/profiles/types/index.js +1 -0
- package/dist/api/resources/send/types/Attachment.d.ts +1 -1
- package/dist/api/resources/send/types/ChannelSource.d.ts +1 -1
- package/dist/api/resources/send/types/Content.d.ts +1 -1
- package/dist/api/resources/send/types/Criteria.d.ts +1 -1
- package/dist/api/resources/send/types/ElementalNode.d.ts +1 -1
- package/dist/api/resources/send/types/ExpiresInType.d.ts +1 -1
- package/dist/api/resources/send/types/IActionButtonStyle.d.ts +1 -1
- package/dist/api/resources/send/types/IAlignment.d.ts +1 -1
- package/dist/api/resources/send/types/IPreferences.d.ts +1 -1
- package/dist/api/resources/send/types/InAppPlacement.d.ts +1 -1
- package/dist/api/resources/send/types/Locales.d.ts +1 -1
- package/dist/api/resources/send/types/Message.d.ts +1 -1
- package/dist/api/resources/send/types/MessageChannels.d.ts +1 -1
- package/dist/api/resources/send/types/MessageData.d.ts +1 -1
- package/dist/api/resources/send/types/MessageProviders.d.ts +1 -1
- package/dist/api/resources/send/types/MessageRecipient.d.ts +1 -1
- package/dist/api/resources/send/types/Recipient.d.ts +1 -1
- package/dist/api/resources/send/types/RecipientData.d.ts +1 -1
- package/dist/api/resources/send/types/RoutingChannel.d.ts +1 -1
- package/dist/api/resources/send/types/RoutingMethod.d.ts +1 -1
- package/dist/api/resources/send/types/RuleType.d.ts +1 -1
- package/dist/api/resources/send/types/TextAlign.d.ts +1 -1
- package/dist/api/resources/send/types/TextStyle.d.ts +1 -1
- package/dist/api/resources/templates/client/Client.d.ts +9 -3
- package/dist/api/resources/templates/client/Client.js +28 -25
- package/dist/api/resources/templates/client/requests/ListTemplatesRequest.d.ts +1 -3
- package/dist/api/resources/templates/types/ChannelIdentifier.d.ts +1 -1
- package/dist/api/resources/templates/types/RoutingStrategyMethod.d.ts +1 -1
- package/dist/api/resources/tenants/client/Client.d.ts +23 -37
- package/dist/api/resources/tenants/client/Client.js +80 -127
- package/dist/api/resources/tenants/client/requests/ListTenantParams.d.ts +1 -5
- package/dist/api/resources/tenants/client/requests/ListUsersForTenantParams.d.ts +1 -4
- package/dist/api/resources/tenants/client/requests/TenantCreateOrReplaceParams.d.ts +6 -21
- package/dist/api/resources/tenants/types/SubscriptionTopicStatus.d.ts +1 -1
- package/dist/api/resources/tenants/types/TemplateProperty.d.ts +1 -1
- package/dist/api/resources/translations/client/Client.d.ts +10 -2
- package/dist/api/resources/translations/client/Client.js +33 -33
- package/dist/api/resources/users/client/Client.d.ts +5 -7
- package/dist/api/resources/users/resources/index.js +17 -7
- package/dist/api/resources/users/resources/preferences/client/Client.d.ts +13 -9
- package/dist/api/resources/users/resources/preferences/client/Client.js +46 -55
- package/dist/api/resources/users/resources/preferences/client/requests/UserPreferencesParams.d.ts +1 -3
- package/dist/api/resources/users/resources/preferences/client/requests/UserPreferencesTopicParams.d.ts +1 -3
- package/dist/api/resources/users/resources/preferences/client/requests/UserPreferencesUpdateParams.d.ts +2 -2
- package/dist/api/resources/users/resources/tenants/client/Client.d.ts +23 -21
- package/dist/api/resources/users/resources/tenants/client/Client.js +68 -89
- package/dist/api/resources/users/resources/tenants/client/requests/AddUserToMultipleTenantsParams.d.ts +9 -8
- package/dist/api/resources/users/resources/tenants/client/requests/AddUserToSingleTenantsParams.d.ts +1 -5
- package/dist/api/resources/users/resources/tenants/client/requests/ListTenantsForUserParams.d.ts +1 -4
- package/dist/api/resources/users/resources/tokens/client/Client.d.ts +27 -29
- package/dist/api/resources/users/resources/tokens/client/Client.js +74 -104
- package/dist/api/resources/users/resources/tokens/types/ExpiryDate.d.ts +1 -1
- package/dist/api/resources/users/resources/tokens/types/GetAllTokensResponse.d.ts +1 -1
- package/dist/api/resources/users/resources/tokens/types/PatchOp.d.ts +1 -1
- package/dist/api/resources/users/resources/tokens/types/ProviderKey.d.ts +1 -1
- package/dist/api/resources/users/resources/tokens/types/TokenStatus.d.ts +1 -1
- package/dist/core/auth/BearerToken.d.ts +1 -1
- package/dist/core/fetcher/APIResponse.d.ts +1 -1
- package/dist/core/fetcher/Fetcher.d.ts +7 -3
- package/dist/core/fetcher/Fetcher.js +30 -135
- package/dist/core/fetcher/Supplier.d.ts +1 -1
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +12 -0
- package/dist/core/fetcher/getFetchFn.d.ts +4 -0
- package/dist/core/fetcher/getFetchFn.js +68 -0
- package/dist/core/fetcher/getHeader.js +1 -2
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +23 -0
- package/dist/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getResponseBody.js +54 -0
- package/dist/core/fetcher/makeRequest.d.ts +1 -0
- package/dist/core/fetcher/makeRequest.js +42 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +40 -0
- package/dist/core/fetcher/signals.d.ts +11 -0
- package/dist/core/fetcher/signals.js +36 -0
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +126 -0
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +59 -0
- package/dist/core/json.d.ts +15 -0
- package/dist/core/json.js +24 -0
- package/dist/core/runtime/runtime.d.ts +2 -1
- package/dist/core/runtime/runtime.js +57 -36
- package/dist/environments.d.ts +1 -1
- package/dist/errors/CourierError.js +2 -1
- package/dist/errors/CourierTimeoutError.d.ts +1 -1
- package/dist/errors/CourierTimeoutError.js +2 -2
- package/dist/index.js +17 -7
- package/dist/version.d.ts +1 -0
- package/dist/version.js +4 -0
- package/environments.d.ts +1 -1
- package/errors/CourierError.js +2 -1
- package/errors/CourierTimeoutError.d.ts +1 -1
- package/errors/CourierTimeoutError.js +2 -2
- package/index.js +17 -7
- package/{jest.config.js → jest.config.mjs} +4 -1
- package/package.json +23 -14
- package/reference.md +5180 -0
- package/scripts/rename-to-esm-files.js +115 -0
- package/version.d.ts +1 -0
- package/version.js +4 -0
package/Client.d.ts
CHANGED
|
@@ -22,12 +22,20 @@ import { Users } from "./api/resources/users/client/Client";
|
|
|
22
22
|
export declare namespace CourierClient {
|
|
23
23
|
interface Options {
|
|
24
24
|
environment?: core.Supplier<environments.CourierEnvironment | string>;
|
|
25
|
+
/** Specify a custom URL to connect the client to. */
|
|
26
|
+
baseUrl?: core.Supplier<string>;
|
|
25
27
|
authorizationToken?: core.Supplier<core.BearerToken | undefined>;
|
|
26
28
|
fetcher?: core.FetchFunction;
|
|
27
29
|
}
|
|
28
30
|
interface RequestOptions {
|
|
31
|
+
/** The maximum time to wait for a response in seconds. */
|
|
29
32
|
timeoutInSeconds?: number;
|
|
33
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
30
34
|
maxRetries?: number;
|
|
35
|
+
/** A hook to abort the request. */
|
|
36
|
+
abortSignal?: AbortSignal;
|
|
37
|
+
/** Additional headers to include in the request. */
|
|
38
|
+
headers?: Record<string, string>;
|
|
31
39
|
}
|
|
32
40
|
interface IdempotentRequestOptions extends RequestOptions {
|
|
33
41
|
idempotencyKey?: string | undefined;
|
|
@@ -36,7 +44,37 @@ export declare namespace CourierClient {
|
|
|
36
44
|
}
|
|
37
45
|
export declare class CourierClient {
|
|
38
46
|
protected readonly _options: CourierClient.Options;
|
|
47
|
+
protected _audiences: Audiences | undefined;
|
|
48
|
+
protected _auditEvents: AuditEvents | undefined;
|
|
49
|
+
protected _authTokens: AuthTokens | undefined;
|
|
50
|
+
protected _automations: Automations | undefined;
|
|
51
|
+
protected _brands: Brands | undefined;
|
|
52
|
+
protected _bulk: Bulk | undefined;
|
|
53
|
+
protected _inbound: Inbound | undefined;
|
|
54
|
+
protected _lists: Lists | undefined;
|
|
55
|
+
protected _messages: Messages | undefined;
|
|
56
|
+
protected _notifications: Notifications | undefined;
|
|
57
|
+
protected _profiles: Profiles | undefined;
|
|
58
|
+
protected _templates: Templates | undefined;
|
|
59
|
+
protected _tenants: Tenants | undefined;
|
|
60
|
+
protected _translations: Translations | undefined;
|
|
61
|
+
protected _users: Users | undefined;
|
|
39
62
|
constructor(_options?: CourierClient.Options);
|
|
63
|
+
get audiences(): Audiences;
|
|
64
|
+
get auditEvents(): AuditEvents;
|
|
65
|
+
get authTokens(): AuthTokens;
|
|
66
|
+
get automations(): Automations;
|
|
67
|
+
get brands(): Brands;
|
|
68
|
+
get bulk(): Bulk;
|
|
69
|
+
get inbound(): Inbound;
|
|
70
|
+
get lists(): Lists;
|
|
71
|
+
get messages(): Messages;
|
|
72
|
+
get notifications(): Notifications;
|
|
73
|
+
get profiles(): Profiles;
|
|
74
|
+
get templates(): Templates;
|
|
75
|
+
get tenants(): Tenants;
|
|
76
|
+
get translations(): Translations;
|
|
77
|
+
get users(): Users;
|
|
40
78
|
/**
|
|
41
79
|
* Use the send API to send a message to one or more recipients.
|
|
42
80
|
*
|
|
@@ -44,123 +82,60 @@ export declare class CourierClient {
|
|
|
44
82
|
* @param {CourierClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
|
|
45
83
|
*
|
|
46
84
|
* @example
|
|
47
|
-
* await
|
|
85
|
+
* await client.send({
|
|
48
86
|
* message: {
|
|
87
|
+
* data: undefined,
|
|
88
|
+
* brand_id: undefined,
|
|
89
|
+
* channels: undefined,
|
|
90
|
+
* context: undefined,
|
|
91
|
+
* metadata: undefined,
|
|
92
|
+
* preferences: undefined,
|
|
93
|
+
* providers: undefined,
|
|
94
|
+
* routing: undefined,
|
|
95
|
+
* timeout: undefined,
|
|
96
|
+
* delay: undefined,
|
|
97
|
+
* expiry: undefined,
|
|
98
|
+
* to: undefined,
|
|
49
99
|
* content: {
|
|
50
|
-
* version: "
|
|
51
|
-
* brand:
|
|
52
|
-
* "key": "value"
|
|
53
|
-
* },
|
|
100
|
+
* version: "version",
|
|
101
|
+
* brand: undefined,
|
|
54
102
|
* elements: [{
|
|
55
|
-
* type: "text"
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* content: undefined
|
|
87
|
-
* },
|
|
88
|
-
* trace_id: "string"
|
|
89
|
-
* },
|
|
90
|
-
* preferences: {
|
|
91
|
-
* subscription_topic_id: "string"
|
|
92
|
-
* },
|
|
93
|
-
* providers: {
|
|
94
|
-
* "string": {
|
|
95
|
-
* override: undefined,
|
|
96
|
-
* if: undefined,
|
|
97
|
-
* timeouts: undefined,
|
|
98
|
-
* metadata: undefined
|
|
99
|
-
* }
|
|
100
|
-
* },
|
|
101
|
-
* routing: {
|
|
102
|
-
* method: Courier.RoutingMethod.All,
|
|
103
|
-
* channels: [{
|
|
104
|
-
* channel: "string",
|
|
105
|
-
* config: undefined,
|
|
106
|
-
* method: undefined,
|
|
107
|
-
* providers: undefined,
|
|
108
|
-
* if: undefined
|
|
103
|
+
* type: "text",
|
|
104
|
+
* channels: undefined,
|
|
105
|
+
* ref: undefined,
|
|
106
|
+
* if: undefined,
|
|
107
|
+
* loop: undefined,
|
|
108
|
+
* content: "content",
|
|
109
|
+
* align: "left",
|
|
110
|
+
* text_style: undefined,
|
|
111
|
+
* color: undefined,
|
|
112
|
+
* bold: undefined,
|
|
113
|
+
* italic: undefined,
|
|
114
|
+
* strikethrough: undefined,
|
|
115
|
+
* underline: undefined,
|
|
116
|
+
* locales: undefined,
|
|
117
|
+
* format: undefined
|
|
118
|
+
* }, {
|
|
119
|
+
* type: "text",
|
|
120
|
+
* channels: undefined,
|
|
121
|
+
* ref: undefined,
|
|
122
|
+
* if: undefined,
|
|
123
|
+
* loop: undefined,
|
|
124
|
+
* content: "content",
|
|
125
|
+
* align: "left",
|
|
126
|
+
* text_style: undefined,
|
|
127
|
+
* color: undefined,
|
|
128
|
+
* bold: undefined,
|
|
129
|
+
* italic: undefined,
|
|
130
|
+
* strikethrough: undefined,
|
|
131
|
+
* underline: undefined,
|
|
132
|
+
* locales: undefined,
|
|
133
|
+
* format: undefined
|
|
109
134
|
* }]
|
|
110
|
-
* },
|
|
111
|
-
* timeout: {
|
|
112
|
-
* provider: {},
|
|
113
|
-
* channel: {},
|
|
114
|
-
* message: 1,
|
|
115
|
-
* escalation: 1,
|
|
116
|
-
* criteria: Courier.Criteria.NoEscalation
|
|
117
|
-
* },
|
|
118
|
-
* delay: {
|
|
119
|
-
* duration: 1,
|
|
120
|
-
* until: "string"
|
|
121
|
-
* },
|
|
122
|
-
* expiry: {
|
|
123
|
-
* expires_at: "string",
|
|
124
|
-
* expires_in: "string"
|
|
125
|
-
* },
|
|
126
|
-
* to: {
|
|
127
|
-
* audience_id: "string",
|
|
128
|
-
* data: {},
|
|
129
|
-
* filters: []
|
|
130
135
|
* }
|
|
131
136
|
* }
|
|
132
137
|
* })
|
|
133
138
|
*/
|
|
134
139
|
send(request: Courier.SendMessageRequest, requestOptions?: CourierClient.IdempotentRequestOptions): Promise<Courier.SendMessageResponse>;
|
|
135
|
-
protected _audiences: Audiences | undefined;
|
|
136
|
-
get audiences(): Audiences;
|
|
137
|
-
protected _auditEvents: AuditEvents | undefined;
|
|
138
|
-
get auditEvents(): AuditEvents;
|
|
139
|
-
protected _authTokens: AuthTokens | undefined;
|
|
140
|
-
get authTokens(): AuthTokens;
|
|
141
|
-
protected _automations: Automations | undefined;
|
|
142
|
-
get automations(): Automations;
|
|
143
|
-
protected _brands: Brands | undefined;
|
|
144
|
-
get brands(): Brands;
|
|
145
|
-
protected _bulk: Bulk | undefined;
|
|
146
|
-
get bulk(): Bulk;
|
|
147
|
-
protected _inbound: Inbound | undefined;
|
|
148
|
-
get inbound(): Inbound;
|
|
149
|
-
protected _lists: Lists | undefined;
|
|
150
|
-
get lists(): Lists;
|
|
151
|
-
protected _messages: Messages | undefined;
|
|
152
|
-
get messages(): Messages;
|
|
153
|
-
protected _notifications: Notifications | undefined;
|
|
154
|
-
get notifications(): Notifications;
|
|
155
|
-
protected _profiles: Profiles | undefined;
|
|
156
|
-
get profiles(): Profiles;
|
|
157
|
-
protected _templates: Templates | undefined;
|
|
158
|
-
get templates(): Templates;
|
|
159
|
-
protected _tenants: Tenants | undefined;
|
|
160
|
-
get tenants(): Tenants;
|
|
161
|
-
protected _translations: Translations | undefined;
|
|
162
|
-
get translations(): Translations;
|
|
163
|
-
protected _users: Users | undefined;
|
|
164
|
-
get users(): Users;
|
|
165
140
|
protected _getAuthorizationHeader(): Promise<string>;
|
|
166
141
|
}
|
package/Client.js
CHANGED
|
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
18
|
}) : function(o, v) {
|
|
19
19
|
o["default"] = v;
|
|
20
20
|
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
28
38
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
39
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
40
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -62,145 +72,6 @@ class CourierClient {
|
|
|
62
72
|
constructor(_options = {}) {
|
|
63
73
|
this._options = _options;
|
|
64
74
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Use the send API to send a message to one or more recipients.
|
|
67
|
-
*
|
|
68
|
-
* @param {Courier.SendMessageRequest} request
|
|
69
|
-
* @param {CourierClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* await courier.send({
|
|
73
|
-
* message: {
|
|
74
|
-
* content: {
|
|
75
|
-
* version: "string",
|
|
76
|
-
* brand: {
|
|
77
|
-
* "key": "value"
|
|
78
|
-
* },
|
|
79
|
-
* elements: [{
|
|
80
|
-
* type: "text"
|
|
81
|
-
* }]
|
|
82
|
-
* },
|
|
83
|
-
* data: {
|
|
84
|
-
* "string": {
|
|
85
|
-
* "key": "value"
|
|
86
|
-
* }
|
|
87
|
-
* },
|
|
88
|
-
* brand_id: "string",
|
|
89
|
-
* channels: {
|
|
90
|
-
* "string": {
|
|
91
|
-
* brand_id: undefined,
|
|
92
|
-
* providers: undefined,
|
|
93
|
-
* routing_method: undefined,
|
|
94
|
-
* if: undefined,
|
|
95
|
-
* timeouts: undefined,
|
|
96
|
-
* override: undefined,
|
|
97
|
-
* metadata: undefined
|
|
98
|
-
* }
|
|
99
|
-
* },
|
|
100
|
-
* context: {
|
|
101
|
-
* tenant_id: "string"
|
|
102
|
-
* },
|
|
103
|
-
* metadata: {
|
|
104
|
-
* event: "string",
|
|
105
|
-
* tags: [],
|
|
106
|
-
* utm: {
|
|
107
|
-
* source: undefined,
|
|
108
|
-
* medium: undefined,
|
|
109
|
-
* campaign: undefined,
|
|
110
|
-
* term: undefined,
|
|
111
|
-
* content: undefined
|
|
112
|
-
* },
|
|
113
|
-
* trace_id: "string"
|
|
114
|
-
* },
|
|
115
|
-
* preferences: {
|
|
116
|
-
* subscription_topic_id: "string"
|
|
117
|
-
* },
|
|
118
|
-
* providers: {
|
|
119
|
-
* "string": {
|
|
120
|
-
* override: undefined,
|
|
121
|
-
* if: undefined,
|
|
122
|
-
* timeouts: undefined,
|
|
123
|
-
* metadata: undefined
|
|
124
|
-
* }
|
|
125
|
-
* },
|
|
126
|
-
* routing: {
|
|
127
|
-
* method: Courier.RoutingMethod.All,
|
|
128
|
-
* channels: [{
|
|
129
|
-
* channel: "string",
|
|
130
|
-
* config: undefined,
|
|
131
|
-
* method: undefined,
|
|
132
|
-
* providers: undefined,
|
|
133
|
-
* if: undefined
|
|
134
|
-
* }]
|
|
135
|
-
* },
|
|
136
|
-
* timeout: {
|
|
137
|
-
* provider: {},
|
|
138
|
-
* channel: {},
|
|
139
|
-
* message: 1,
|
|
140
|
-
* escalation: 1,
|
|
141
|
-
* criteria: Courier.Criteria.NoEscalation
|
|
142
|
-
* },
|
|
143
|
-
* delay: {
|
|
144
|
-
* duration: 1,
|
|
145
|
-
* until: "string"
|
|
146
|
-
* },
|
|
147
|
-
* expiry: {
|
|
148
|
-
* expires_at: "string",
|
|
149
|
-
* expires_in: "string"
|
|
150
|
-
* },
|
|
151
|
-
* to: {
|
|
152
|
-
* audience_id: "string",
|
|
153
|
-
* data: {},
|
|
154
|
-
* filters: []
|
|
155
|
-
* }
|
|
156
|
-
* }
|
|
157
|
-
* })
|
|
158
|
-
*/
|
|
159
|
-
send(request, requestOptions) {
|
|
160
|
-
var _a, _b;
|
|
161
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
163
|
-
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CourierEnvironment.Production, "/send"),
|
|
164
|
-
method: "POST",
|
|
165
|
-
headers: {
|
|
166
|
-
Authorization: yield this._getAuthorizationHeader(),
|
|
167
|
-
"X-Fern-Language": "JavaScript",
|
|
168
|
-
"X-Fern-SDK-Name": "@trycourier/courier",
|
|
169
|
-
"X-Fern-SDK-Version": "v6.3.1",
|
|
170
|
-
"X-Fern-Runtime": core.RUNTIME.type,
|
|
171
|
-
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
172
|
-
"Idempotency-Key": (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey) != null ? requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey : undefined,
|
|
173
|
-
"X-Idempotency-Expiration": (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyExpiry) != null ? requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyExpiry : undefined,
|
|
174
|
-
},
|
|
175
|
-
contentType: "application/json",
|
|
176
|
-
body: request,
|
|
177
|
-
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
178
|
-
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
179
|
-
});
|
|
180
|
-
if (_response.ok) {
|
|
181
|
-
return _response.body;
|
|
182
|
-
}
|
|
183
|
-
if (_response.error.reason === "status-code") {
|
|
184
|
-
throw new errors.CourierError({
|
|
185
|
-
statusCode: _response.error.statusCode,
|
|
186
|
-
body: _response.error.body,
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
switch (_response.error.reason) {
|
|
190
|
-
case "non-json":
|
|
191
|
-
throw new errors.CourierError({
|
|
192
|
-
statusCode: _response.error.statusCode,
|
|
193
|
-
body: _response.error.rawBody,
|
|
194
|
-
});
|
|
195
|
-
case "timeout":
|
|
196
|
-
throw new errors.CourierTimeoutError();
|
|
197
|
-
case "unknown":
|
|
198
|
-
throw new errors.CourierError({
|
|
199
|
-
message: _response.error.errorMessage,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
75
|
get audiences() {
|
|
205
76
|
var _a;
|
|
206
77
|
return ((_a = this._audiences) !== null && _a !== void 0 ? _a : (this._audiences = new Client_1.Audiences(this._options)));
|
|
@@ -261,13 +132,112 @@ class CourierClient {
|
|
|
261
132
|
var _a;
|
|
262
133
|
return ((_a = this._users) !== null && _a !== void 0 ? _a : (this._users = new Client_15.Users(this._options)));
|
|
263
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Use the send API to send a message to one or more recipients.
|
|
137
|
+
*
|
|
138
|
+
* @param {Courier.SendMessageRequest} request
|
|
139
|
+
* @param {CourierClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* await client.send({
|
|
143
|
+
* message: {
|
|
144
|
+
* data: undefined,
|
|
145
|
+
* brand_id: undefined,
|
|
146
|
+
* channels: undefined,
|
|
147
|
+
* context: undefined,
|
|
148
|
+
* metadata: undefined,
|
|
149
|
+
* preferences: undefined,
|
|
150
|
+
* providers: undefined,
|
|
151
|
+
* routing: undefined,
|
|
152
|
+
* timeout: undefined,
|
|
153
|
+
* delay: undefined,
|
|
154
|
+
* expiry: undefined,
|
|
155
|
+
* to: undefined,
|
|
156
|
+
* content: {
|
|
157
|
+
* version: "version",
|
|
158
|
+
* brand: undefined,
|
|
159
|
+
* elements: [{
|
|
160
|
+
* type: "text",
|
|
161
|
+
* channels: undefined,
|
|
162
|
+
* ref: undefined,
|
|
163
|
+
* if: undefined,
|
|
164
|
+
* loop: undefined,
|
|
165
|
+
* content: "content",
|
|
166
|
+
* align: "left",
|
|
167
|
+
* text_style: undefined,
|
|
168
|
+
* color: undefined,
|
|
169
|
+
* bold: undefined,
|
|
170
|
+
* italic: undefined,
|
|
171
|
+
* strikethrough: undefined,
|
|
172
|
+
* underline: undefined,
|
|
173
|
+
* locales: undefined,
|
|
174
|
+
* format: undefined
|
|
175
|
+
* }, {
|
|
176
|
+
* type: "text",
|
|
177
|
+
* channels: undefined,
|
|
178
|
+
* ref: undefined,
|
|
179
|
+
* if: undefined,
|
|
180
|
+
* loop: undefined,
|
|
181
|
+
* content: "content",
|
|
182
|
+
* align: "left",
|
|
183
|
+
* text_style: undefined,
|
|
184
|
+
* color: undefined,
|
|
185
|
+
* bold: undefined,
|
|
186
|
+
* italic: undefined,
|
|
187
|
+
* strikethrough: undefined,
|
|
188
|
+
* underline: undefined,
|
|
189
|
+
* locales: undefined,
|
|
190
|
+
* format: undefined
|
|
191
|
+
* }]
|
|
192
|
+
* }
|
|
193
|
+
* }
|
|
194
|
+
* })
|
|
195
|
+
*/
|
|
196
|
+
send(request, requestOptions) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
var _a, _b, _c;
|
|
199
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
200
|
+
url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CourierEnvironment.Production, "/send"),
|
|
201
|
+
method: "POST",
|
|
202
|
+
headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@trycourier/courier", "X-Fern-SDK-Version": "6.4.0", "User-Agent": "@trycourier/courier/6.4.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Idempotency-Key": (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey) != null ? requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey : undefined, "X-Idempotency-Expiration": (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyExpiry) != null ? requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyExpiry : undefined }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
203
|
+
contentType: "application/json",
|
|
204
|
+
requestType: "json",
|
|
205
|
+
body: request,
|
|
206
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
207
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
208
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
209
|
+
});
|
|
210
|
+
if (_response.ok) {
|
|
211
|
+
return _response.body;
|
|
212
|
+
}
|
|
213
|
+
if (_response.error.reason === "status-code") {
|
|
214
|
+
throw new errors.CourierError({
|
|
215
|
+
statusCode: _response.error.statusCode,
|
|
216
|
+
body: _response.error.body,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
switch (_response.error.reason) {
|
|
220
|
+
case "non-json":
|
|
221
|
+
throw new errors.CourierError({
|
|
222
|
+
statusCode: _response.error.statusCode,
|
|
223
|
+
body: _response.error.rawBody,
|
|
224
|
+
});
|
|
225
|
+
case "timeout":
|
|
226
|
+
throw new errors.CourierTimeoutError("Timeout exceeded when calling POST /send.");
|
|
227
|
+
case "unknown":
|
|
228
|
+
throw new errors.CourierError({
|
|
229
|
+
message: _response.error.errorMessage,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
264
234
|
_getAuthorizationHeader() {
|
|
265
|
-
var _a;
|
|
266
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
var _a;
|
|
267
237
|
const bearer = (_a = (yield core.Supplier.get(this._options.authorizationToken))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env["COURIER_AUTH_TOKEN"];
|
|
268
238
|
if (bearer == null) {
|
|
269
239
|
throw new errors.CourierError({
|
|
270
|
-
message: "Please specify
|
|
240
|
+
message: "Please specify a bearer by either passing it in to the constructor or initializing a COURIER_AUTH_TOKEN environment variable",
|
|
271
241
|
});
|
|
272
242
|
}
|
|
273
243
|
return `Bearer ${bearer}`;
|
|
@@ -6,87 +6,54 @@ import * as Courier from "../../index";
|
|
|
6
6
|
* @example
|
|
7
7
|
* {
|
|
8
8
|
* message: {
|
|
9
|
+
* data: undefined,
|
|
10
|
+
* brand_id: undefined,
|
|
11
|
+
* channels: undefined,
|
|
12
|
+
* context: undefined,
|
|
13
|
+
* metadata: undefined,
|
|
14
|
+
* preferences: undefined,
|
|
15
|
+
* providers: undefined,
|
|
16
|
+
* routing: undefined,
|
|
17
|
+
* timeout: undefined,
|
|
18
|
+
* delay: undefined,
|
|
19
|
+
* expiry: undefined,
|
|
20
|
+
* to: undefined,
|
|
9
21
|
* content: {
|
|
10
|
-
* version: "
|
|
11
|
-
* brand:
|
|
12
|
-
* "key": "value"
|
|
13
|
-
* },
|
|
22
|
+
* version: "version",
|
|
23
|
+
* brand: undefined,
|
|
14
24
|
* elements: [{
|
|
15
|
-
* type: "text"
|
|
25
|
+
* type: "text",
|
|
26
|
+
* channels: undefined,
|
|
27
|
+
* ref: undefined,
|
|
28
|
+
* if: undefined,
|
|
29
|
+
* loop: undefined,
|
|
30
|
+
* content: "content",
|
|
31
|
+
* align: "left",
|
|
32
|
+
* text_style: undefined,
|
|
33
|
+
* color: undefined,
|
|
34
|
+
* bold: undefined,
|
|
35
|
+
* italic: undefined,
|
|
36
|
+
* strikethrough: undefined,
|
|
37
|
+
* underline: undefined,
|
|
38
|
+
* locales: undefined,
|
|
39
|
+
* format: undefined
|
|
40
|
+
* }, {
|
|
41
|
+
* type: "text",
|
|
42
|
+
* channels: undefined,
|
|
43
|
+
* ref: undefined,
|
|
44
|
+
* if: undefined,
|
|
45
|
+
* loop: undefined,
|
|
46
|
+
* content: "content",
|
|
47
|
+
* align: "left",
|
|
48
|
+
* text_style: undefined,
|
|
49
|
+
* color: undefined,
|
|
50
|
+
* bold: undefined,
|
|
51
|
+
* italic: undefined,
|
|
52
|
+
* strikethrough: undefined,
|
|
53
|
+
* underline: undefined,
|
|
54
|
+
* locales: undefined,
|
|
55
|
+
* format: undefined
|
|
16
56
|
* }]
|
|
17
|
-
* },
|
|
18
|
-
* data: {
|
|
19
|
-
* "string": {
|
|
20
|
-
* "key": "value"
|
|
21
|
-
* }
|
|
22
|
-
* },
|
|
23
|
-
* brand_id: "string",
|
|
24
|
-
* channels: {
|
|
25
|
-
* "string": {
|
|
26
|
-
* brand_id: undefined,
|
|
27
|
-
* providers: undefined,
|
|
28
|
-
* routing_method: undefined,
|
|
29
|
-
* if: undefined,
|
|
30
|
-
* timeouts: undefined,
|
|
31
|
-
* override: undefined,
|
|
32
|
-
* metadata: undefined
|
|
33
|
-
* }
|
|
34
|
-
* },
|
|
35
|
-
* context: {
|
|
36
|
-
* tenant_id: "string"
|
|
37
|
-
* },
|
|
38
|
-
* metadata: {
|
|
39
|
-
* event: "string",
|
|
40
|
-
* tags: [],
|
|
41
|
-
* utm: {
|
|
42
|
-
* source: undefined,
|
|
43
|
-
* medium: undefined,
|
|
44
|
-
* campaign: undefined,
|
|
45
|
-
* term: undefined,
|
|
46
|
-
* content: undefined
|
|
47
|
-
* },
|
|
48
|
-
* trace_id: "string"
|
|
49
|
-
* },
|
|
50
|
-
* preferences: {
|
|
51
|
-
* subscription_topic_id: "string"
|
|
52
|
-
* },
|
|
53
|
-
* providers: {
|
|
54
|
-
* "string": {
|
|
55
|
-
* override: undefined,
|
|
56
|
-
* if: undefined,
|
|
57
|
-
* timeouts: undefined,
|
|
58
|
-
* metadata: undefined
|
|
59
|
-
* }
|
|
60
|
-
* },
|
|
61
|
-
* routing: {
|
|
62
|
-
* method: Courier.RoutingMethod.All,
|
|
63
|
-
* channels: [{
|
|
64
|
-
* channel: "string",
|
|
65
|
-
* config: undefined,
|
|
66
|
-
* method: undefined,
|
|
67
|
-
* providers: undefined,
|
|
68
|
-
* if: undefined
|
|
69
|
-
* }]
|
|
70
|
-
* },
|
|
71
|
-
* timeout: {
|
|
72
|
-
* provider: {},
|
|
73
|
-
* channel: {},
|
|
74
|
-
* message: 1,
|
|
75
|
-
* escalation: 1,
|
|
76
|
-
* criteria: Courier.Criteria.NoEscalation
|
|
77
|
-
* },
|
|
78
|
-
* delay: {
|
|
79
|
-
* duration: 1,
|
|
80
|
-
* until: "string"
|
|
81
|
-
* },
|
|
82
|
-
* expiry: {
|
|
83
|
-
* expires_at: "string",
|
|
84
|
-
* expires_in: "string"
|
|
85
|
-
* },
|
|
86
|
-
* to: {
|
|
87
|
-
* audience_id: "string",
|
|
88
|
-
* data: {},
|
|
89
|
-
* filters: []
|
|
90
57
|
* }
|
|
91
58
|
* }
|
|
92
59
|
* }
|