@trycourier/courier 6.3.1 → 6.4.1
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 +49 -108
- package/Client.js +89 -148
- package/README.md +113 -808
- package/api/client/requests/SendMessageRequest.d.ts +8 -76
- package/api/resources/audiences/client/Client.d.ts +26 -21
- package/api/resources/audiences/client/Client.js +97 -90
- 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 +14 -6
- package/api/resources/auditEvents/client/Client.js +48 -38
- package/api/resources/auditEvents/client/requests/ListAuditEventsRequest.d.ts +1 -3
- package/api/resources/authTokens/client/Client.d.ts +13 -4
- package/api/resources/authTokens/client/Client.js +35 -26
- package/api/resources/authTokens/client/requests/IssueTokenParams.d.ts +2 -2
- package/api/resources/automations/client/Client.d.ts +19 -15
- package/api/resources/automations/client/Client.js +52 -50
- 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 +32 -63
- package/api/resources/brands/client/Client.js +103 -134
- 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 +40 -126
- package/api/resources/bulk/client/Client.js +111 -201
- 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.d.ts +2 -1
- package/api/resources/commons/errors/AlreadyExistsError.js +19 -8
- package/api/resources/commons/errors/BadRequestError.d.ts +2 -1
- package/api/resources/commons/errors/BadRequestError.js +19 -8
- package/api/resources/commons/errors/ConflictError.d.ts +2 -1
- package/api/resources/commons/errors/ConflictError.js +19 -8
- package/api/resources/commons/errors/MessageNotFoundError.d.ts +2 -1
- package/api/resources/commons/errors/MessageNotFoundError.js +19 -8
- package/api/resources/commons/errors/NotFoundError.d.ts +2 -1
- package/api/resources/commons/errors/NotFoundError.js +19 -8
- package/api/resources/commons/errors/PaymentRequiredError.d.ts +2 -1
- package/api/resources/commons/errors/PaymentRequiredError.js +19 -8
- 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 +11 -2
- package/api/resources/inbound/client/Client.js +35 -24
- package/api/resources/index.js +17 -7
- package/api/resources/lists/client/Client.d.ts +51 -44
- package/api/resources/lists/client/Client.js +181 -174
- 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 +26 -29
- package/api/resources/messages/client/Client.js +111 -114
- 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 +32 -17
- package/api/resources/notifications/client/Client.js +119 -93
- 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 +50 -30
- package/api/resources/profiles/client/Client.js +160 -139
- 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 +11 -4
- package/api/resources/templates/client/Client.js +34 -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 +37 -44
- package/api/resources/tenants/client/Client.js +130 -135
- 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 +14 -4
- package/api/resources/translations/client/Client.js +49 -37
- 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 +19 -12
- package/api/resources/users/resources/preferences/client/Client.js +77 -59
- 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 +33 -26
- package/api/resources/users/resources/tenants/client/Client.js +104 -92
- 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 +39 -35
- package/api/resources/users/resources/tokens/client/Client.js +121 -115
- 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 +11 -1
- package/core/fetcher/Fetcher.d.ts +7 -3
- package/core/fetcher/Fetcher.js +37 -135
- package/core/fetcher/Headers.d.ts +2 -0
- package/core/fetcher/Headers.js +84 -0
- package/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/core/fetcher/HttpResponsePromise.js +103 -0
- package/core/fetcher/RawResponse.d.ts +29 -0
- package/core/fetcher/RawResponse.js +44 -0
- 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/index.d.ts +3 -0
- package/core/fetcher/index.js +7 -1
- 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/index.d.ts +1 -1
- package/core/index.js +1 -1
- 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 +49 -108
- package/dist/Client.js +89 -148
- package/dist/api/client/requests/SendMessageRequest.d.ts +8 -76
- package/dist/api/resources/audiences/client/Client.d.ts +26 -21
- package/dist/api/resources/audiences/client/Client.js +97 -90
- 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 +14 -6
- package/dist/api/resources/auditEvents/client/Client.js +48 -38
- package/dist/api/resources/auditEvents/client/requests/ListAuditEventsRequest.d.ts +1 -3
- package/dist/api/resources/authTokens/client/Client.d.ts +13 -4
- package/dist/api/resources/authTokens/client/Client.js +35 -26
- package/dist/api/resources/authTokens/client/requests/IssueTokenParams.d.ts +2 -2
- package/dist/api/resources/automations/client/Client.d.ts +19 -15
- package/dist/api/resources/automations/client/Client.js +52 -50
- 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 +32 -63
- package/dist/api/resources/brands/client/Client.js +103 -134
- 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 +40 -126
- package/dist/api/resources/bulk/client/Client.js +111 -201
- 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.d.ts +2 -1
- package/dist/api/resources/commons/errors/AlreadyExistsError.js +19 -8
- package/dist/api/resources/commons/errors/BadRequestError.d.ts +2 -1
- package/dist/api/resources/commons/errors/BadRequestError.js +19 -8
- package/dist/api/resources/commons/errors/ConflictError.d.ts +2 -1
- package/dist/api/resources/commons/errors/ConflictError.js +19 -8
- package/dist/api/resources/commons/errors/MessageNotFoundError.d.ts +2 -1
- package/dist/api/resources/commons/errors/MessageNotFoundError.js +19 -8
- package/dist/api/resources/commons/errors/NotFoundError.d.ts +2 -1
- package/dist/api/resources/commons/errors/NotFoundError.js +19 -8
- package/dist/api/resources/commons/errors/PaymentRequiredError.d.ts +2 -1
- package/dist/api/resources/commons/errors/PaymentRequiredError.js +19 -8
- 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 +11 -2
- package/dist/api/resources/inbound/client/Client.js +35 -24
- package/dist/api/resources/index.js +17 -7
- package/dist/api/resources/lists/client/Client.d.ts +51 -44
- package/dist/api/resources/lists/client/Client.js +181 -174
- 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 +26 -29
- package/dist/api/resources/messages/client/Client.js +111 -114
- 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 +32 -17
- package/dist/api/resources/notifications/client/Client.js +119 -93
- 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 +50 -30
- package/dist/api/resources/profiles/client/Client.js +160 -139
- 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 +11 -4
- package/dist/api/resources/templates/client/Client.js +34 -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 +37 -44
- package/dist/api/resources/tenants/client/Client.js +130 -135
- 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 +14 -4
- package/dist/api/resources/translations/client/Client.js +49 -37
- 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 +19 -12
- package/dist/api/resources/users/resources/preferences/client/Client.js +77 -59
- 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 +33 -26
- package/dist/api/resources/users/resources/tenants/client/Client.js +104 -92
- 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 +39 -35
- package/dist/api/resources/users/resources/tokens/client/Client.js +121 -115
- 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 +11 -1
- package/dist/core/fetcher/Fetcher.d.ts +7 -3
- package/dist/core/fetcher/Fetcher.js +37 -135
- package/dist/core/fetcher/Headers.d.ts +2 -0
- package/dist/core/fetcher/Headers.js +84 -0
- package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/core/fetcher/HttpResponsePromise.js +103 -0
- package/dist/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/core/fetcher/RawResponse.js +44 -0
- 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/index.d.ts +3 -0
- package/dist/core/fetcher/index.js +7 -1
- 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/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- 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.d.ts +4 -1
- package/dist/errors/CourierError.js +6 -8
- 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.d.ts +4 -1
- package/errors/CourierError.js +6 -8
- 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 +25 -15
- package/reference.md +5142 -0
- package/scripts/rename-to-esm-files.js +115 -0
- package/version.d.ts +1 -0
- package/version.js +4 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.NodePre18StreamWrapper = void 0;
|
|
20
|
+
class NodePre18StreamWrapper {
|
|
21
|
+
constructor(readableStream) {
|
|
22
|
+
this.readableStream = readableStream;
|
|
23
|
+
}
|
|
24
|
+
on(event, callback) {
|
|
25
|
+
this.readableStream.on(event, callback);
|
|
26
|
+
}
|
|
27
|
+
off(event, callback) {
|
|
28
|
+
this.readableStream.off(event, callback);
|
|
29
|
+
}
|
|
30
|
+
pipe(dest) {
|
|
31
|
+
this.readableStream.pipe(dest);
|
|
32
|
+
return dest;
|
|
33
|
+
}
|
|
34
|
+
pipeTo(dest) {
|
|
35
|
+
return this.pipe(dest);
|
|
36
|
+
}
|
|
37
|
+
unpipe(dest) {
|
|
38
|
+
if (dest) {
|
|
39
|
+
this.readableStream.unpipe(dest);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.readableStream.unpipe();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
destroy(error) {
|
|
46
|
+
this.readableStream.destroy(error);
|
|
47
|
+
}
|
|
48
|
+
pause() {
|
|
49
|
+
this.readableStream.pause();
|
|
50
|
+
}
|
|
51
|
+
resume() {
|
|
52
|
+
this.readableStream.resume();
|
|
53
|
+
}
|
|
54
|
+
get isPaused() {
|
|
55
|
+
return this.readableStream.isPaused();
|
|
56
|
+
}
|
|
57
|
+
read() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const chunk = this.readableStream.read();
|
|
61
|
+
if (chunk) {
|
|
62
|
+
resolve(chunk);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.readableStream.once("readable", () => {
|
|
66
|
+
const chunk = this.readableStream.read();
|
|
67
|
+
resolve(chunk);
|
|
68
|
+
});
|
|
69
|
+
this.readableStream.once("error", reject);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
setEncoding(encoding) {
|
|
75
|
+
this.readableStream.setEncoding(encoding);
|
|
76
|
+
this.encoding = encoding;
|
|
77
|
+
}
|
|
78
|
+
text() {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
var _a, e_1, _b, _c;
|
|
81
|
+
const chunks = [];
|
|
82
|
+
const encoder = new TextEncoder();
|
|
83
|
+
this.readableStream.setEncoding((this.encoding || "utf-8"));
|
|
84
|
+
try {
|
|
85
|
+
for (var _d = true, _e = __asyncValues(this.readableStream), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
86
|
+
_c = _f.value;
|
|
87
|
+
_d = false;
|
|
88
|
+
const chunk = _c;
|
|
89
|
+
chunks.push(encoder.encode(chunk));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
96
|
+
}
|
|
97
|
+
finally { if (e_1) throw e_1.error; }
|
|
98
|
+
}
|
|
99
|
+
const decoder = new TextDecoder(this.encoding || "utf-8");
|
|
100
|
+
return decoder.decode(Buffer.concat(chunks));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
json() {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const text = yield this.text();
|
|
106
|
+
return JSON.parse(text);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
[Symbol.asyncIterator]() {
|
|
110
|
+
const readableStream = this.readableStream;
|
|
111
|
+
const iterator = readableStream[Symbol.asyncIterator]();
|
|
112
|
+
// Create and return an async iterator that yields buffers
|
|
113
|
+
return {
|
|
114
|
+
next() {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
const { value, done } = yield iterator.next();
|
|
117
|
+
return { value: value, done };
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
[Symbol.asyncIterator]() {
|
|
121
|
+
return this;
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.NodePre18StreamWrapper = NodePre18StreamWrapper;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StreamWrapper } from "./chooseStreamWrapper";
|
|
2
|
+
type EventCallback = (data?: any) => void;
|
|
3
|
+
export declare class UndiciStreamWrapper<ReadFormat extends Uint8Array | Uint16Array | Uint32Array> implements StreamWrapper<UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>, ReadFormat> {
|
|
4
|
+
private readableStream;
|
|
5
|
+
private reader;
|
|
6
|
+
private events;
|
|
7
|
+
private paused;
|
|
8
|
+
private resumeCallback;
|
|
9
|
+
private encoding;
|
|
10
|
+
constructor(readableStream: ReadableStream<ReadFormat>);
|
|
11
|
+
on(event: string, callback: EventCallback): void;
|
|
12
|
+
off(event: string, callback: EventCallback): void;
|
|
13
|
+
pipe(dest: UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>): UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>;
|
|
14
|
+
pipeTo(dest: UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>): UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>;
|
|
15
|
+
unpipe(dest: UndiciStreamWrapper<ReadFormat> | WritableStream): void;
|
|
16
|
+
destroy(error?: Error): void;
|
|
17
|
+
pause(): void;
|
|
18
|
+
resume(): void;
|
|
19
|
+
get isPaused(): boolean;
|
|
20
|
+
read(): Promise<ReadFormat | undefined>;
|
|
21
|
+
setEncoding(encoding: string): void;
|
|
22
|
+
text(): Promise<string>;
|
|
23
|
+
json<T>(): Promise<T>;
|
|
24
|
+
private _write;
|
|
25
|
+
private _end;
|
|
26
|
+
private _error;
|
|
27
|
+
private _emit;
|
|
28
|
+
private _startReading;
|
|
29
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<ReadFormat>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UndiciStreamWrapper = void 0;
|
|
13
|
+
class UndiciStreamWrapper {
|
|
14
|
+
constructor(readableStream) {
|
|
15
|
+
this.readableStream = readableStream;
|
|
16
|
+
this.reader = this.readableStream.getReader();
|
|
17
|
+
this.events = {
|
|
18
|
+
data: [],
|
|
19
|
+
end: [],
|
|
20
|
+
error: [],
|
|
21
|
+
readable: [],
|
|
22
|
+
close: [],
|
|
23
|
+
pause: [],
|
|
24
|
+
resume: [],
|
|
25
|
+
};
|
|
26
|
+
this.paused = false;
|
|
27
|
+
this.resumeCallback = null;
|
|
28
|
+
this.encoding = null;
|
|
29
|
+
}
|
|
30
|
+
on(event, callback) {
|
|
31
|
+
var _a;
|
|
32
|
+
(_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.push(callback);
|
|
33
|
+
}
|
|
34
|
+
off(event, callback) {
|
|
35
|
+
var _a;
|
|
36
|
+
this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((cb) => cb !== callback);
|
|
37
|
+
}
|
|
38
|
+
pipe(dest) {
|
|
39
|
+
this.on("data", (chunk) => {
|
|
40
|
+
if (dest instanceof UndiciStreamWrapper) {
|
|
41
|
+
dest._write(chunk);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const writer = dest.getWriter();
|
|
45
|
+
writer.write(chunk).then(() => writer.releaseLock());
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
this.on("end", () => {
|
|
49
|
+
if (dest instanceof UndiciStreamWrapper) {
|
|
50
|
+
dest._end();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const writer = dest.getWriter();
|
|
54
|
+
writer.close();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
this.on("error", (error) => {
|
|
58
|
+
if (dest instanceof UndiciStreamWrapper) {
|
|
59
|
+
dest._error(error);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const writer = dest.getWriter();
|
|
63
|
+
writer.abort(error);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
this._startReading();
|
|
67
|
+
return dest;
|
|
68
|
+
}
|
|
69
|
+
pipeTo(dest) {
|
|
70
|
+
return this.pipe(dest);
|
|
71
|
+
}
|
|
72
|
+
unpipe(dest) {
|
|
73
|
+
this.off("data", (chunk) => {
|
|
74
|
+
if (dest instanceof UndiciStreamWrapper) {
|
|
75
|
+
dest._write(chunk);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const writer = dest.getWriter();
|
|
79
|
+
writer.write(chunk).then(() => writer.releaseLock());
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
this.off("end", () => {
|
|
83
|
+
if (dest instanceof UndiciStreamWrapper) {
|
|
84
|
+
dest._end();
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const writer = dest.getWriter();
|
|
88
|
+
writer.close();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
this.off("error", (error) => {
|
|
92
|
+
if (dest instanceof UndiciStreamWrapper) {
|
|
93
|
+
dest._error(error);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const writer = dest.getWriter();
|
|
97
|
+
writer.abort(error);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
destroy(error) {
|
|
102
|
+
this.reader
|
|
103
|
+
.cancel(error)
|
|
104
|
+
.then(() => {
|
|
105
|
+
this._emit("close");
|
|
106
|
+
})
|
|
107
|
+
.catch((err) => {
|
|
108
|
+
this._emit("error", err);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
pause() {
|
|
112
|
+
this.paused = true;
|
|
113
|
+
this._emit("pause");
|
|
114
|
+
}
|
|
115
|
+
resume() {
|
|
116
|
+
if (this.paused) {
|
|
117
|
+
this.paused = false;
|
|
118
|
+
this._emit("resume");
|
|
119
|
+
if (this.resumeCallback) {
|
|
120
|
+
this.resumeCallback();
|
|
121
|
+
this.resumeCallback = null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
get isPaused() {
|
|
126
|
+
return this.paused;
|
|
127
|
+
}
|
|
128
|
+
read() {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
if (this.paused) {
|
|
131
|
+
yield new Promise((resolve) => {
|
|
132
|
+
this.resumeCallback = resolve;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const { done, value } = yield this.reader.read();
|
|
136
|
+
if (done) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
setEncoding(encoding) {
|
|
143
|
+
this.encoding = encoding;
|
|
144
|
+
}
|
|
145
|
+
text() {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const chunks = [];
|
|
148
|
+
while (true) {
|
|
149
|
+
const { done, value } = yield this.reader.read();
|
|
150
|
+
if (done) {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
if (value) {
|
|
154
|
+
chunks.push(value);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const decoder = new TextDecoder(this.encoding || "utf-8");
|
|
158
|
+
return decoder.decode(yield new Blob(chunks).arrayBuffer());
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
json() {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
const text = yield this.text();
|
|
164
|
+
return JSON.parse(text);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
_write(chunk) {
|
|
168
|
+
this._emit("data", chunk);
|
|
169
|
+
}
|
|
170
|
+
_end() {
|
|
171
|
+
this._emit("end");
|
|
172
|
+
}
|
|
173
|
+
_error(error) {
|
|
174
|
+
this._emit("error", error);
|
|
175
|
+
}
|
|
176
|
+
_emit(event, data) {
|
|
177
|
+
if (this.events[event]) {
|
|
178
|
+
for (const callback of this.events[event] || []) {
|
|
179
|
+
callback(data);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
_startReading() {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
try {
|
|
186
|
+
this._emit("readable");
|
|
187
|
+
while (true) {
|
|
188
|
+
if (this.paused) {
|
|
189
|
+
yield new Promise((resolve) => {
|
|
190
|
+
this.resumeCallback = resolve;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
const { done, value } = yield this.reader.read();
|
|
194
|
+
if (done) {
|
|
195
|
+
this._emit("end");
|
|
196
|
+
this._emit("close");
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (value) {
|
|
200
|
+
this._emit("data", value);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
this._emit("error", error);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
[Symbol.asyncIterator]() {
|
|
210
|
+
return {
|
|
211
|
+
next: () => __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
if (this.paused) {
|
|
213
|
+
yield new Promise((resolve) => {
|
|
214
|
+
this.resumeCallback = resolve;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
const { done, value } = yield this.reader.read();
|
|
218
|
+
if (done) {
|
|
219
|
+
return { done: true, value: undefined };
|
|
220
|
+
}
|
|
221
|
+
return { done: false, value };
|
|
222
|
+
}),
|
|
223
|
+
[Symbol.asyncIterator]() {
|
|
224
|
+
return this;
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.UndiciStreamWrapper = UndiciStreamWrapper;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type EventCallback = (data?: any) => void;
|
|
2
|
+
export interface StreamWrapper<WritableStream, ReadFormat> {
|
|
3
|
+
setEncoding(encoding?: string): void;
|
|
4
|
+
on(event: string, callback: EventCallback): void;
|
|
5
|
+
off(event: string, callback: EventCallback): void;
|
|
6
|
+
pipe(dest: WritableStream): WritableStream;
|
|
7
|
+
pipeTo(dest: WritableStream): WritableStream;
|
|
8
|
+
unpipe(dest?: WritableStream): void;
|
|
9
|
+
destroy(error?: Error): void;
|
|
10
|
+
pause(): void;
|
|
11
|
+
resume(): void;
|
|
12
|
+
get isPaused(): boolean;
|
|
13
|
+
read(): Promise<ReadFormat | undefined>;
|
|
14
|
+
text(): Promise<string>;
|
|
15
|
+
json<T>(): Promise<T>;
|
|
16
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<ReadFormat>;
|
|
17
|
+
}
|
|
18
|
+
export declare function chooseStreamWrapper(responseBody: any): Promise<Promise<StreamWrapper<any, any>>>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.chooseStreamWrapper = chooseStreamWrapper;
|
|
46
|
+
const runtime_1 = require("../../runtime");
|
|
47
|
+
function chooseStreamWrapper(responseBody) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (runtime_1.RUNTIME.type === "node" && runtime_1.RUNTIME.parsedVersion != null && runtime_1.RUNTIME.parsedVersion >= 18) {
|
|
50
|
+
return new (yield Promise.resolve().then(() => __importStar(require("./Node18UniversalStreamWrapper")))).Node18UniversalStreamWrapper(responseBody);
|
|
51
|
+
}
|
|
52
|
+
else if (runtime_1.RUNTIME.type !== "node" && typeof fetch === "function") {
|
|
53
|
+
return new (yield Promise.resolve().then(() => __importStar(require("./UndiciStreamWrapper")))).UndiciStreamWrapper(responseBody);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return new (yield Promise.resolve().then(() => __importStar(require("./NodePre18StreamWrapper")))).NodePre18StreamWrapper(responseBody);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -15,5 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./fetcher"), exports);
|
|
18
|
-
__exportStar(require("./auth"), exports);
|
|
19
18
|
__exportStar(require("./runtime"), exports);
|
|
19
|
+
__exportStar(require("./auth"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize a value to JSON
|
|
3
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
4
|
+
* @param replacer A function that transforms the results.
|
|
5
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
6
|
+
* @returns JSON string
|
|
7
|
+
*/
|
|
8
|
+
export declare const toJson: (value: unknown, replacer?: (this: unknown, key: string, value: unknown) => unknown, space?: string | number) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Parse JSON string to object, array, or other type
|
|
11
|
+
* @param text A valid JSON string.
|
|
12
|
+
* @param reviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
|
|
13
|
+
* @returns Parsed object, array, or other type
|
|
14
|
+
*/
|
|
15
|
+
export declare function fromJson<T = unknown>(text: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): T;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toJson = void 0;
|
|
4
|
+
exports.fromJson = fromJson;
|
|
5
|
+
/**
|
|
6
|
+
* Serialize a value to JSON
|
|
7
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
8
|
+
* @param replacer A function that transforms the results.
|
|
9
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
10
|
+
* @returns JSON string
|
|
11
|
+
*/
|
|
12
|
+
const toJson = (value, replacer, space) => {
|
|
13
|
+
return JSON.stringify(value, replacer, space);
|
|
14
|
+
};
|
|
15
|
+
exports.toJson = toJson;
|
|
16
|
+
/**
|
|
17
|
+
* Parse JSON string to object, array, or other type
|
|
18
|
+
* @param text A valid JSON string.
|
|
19
|
+
* @param reviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
|
|
20
|
+
* @returns Parsed object, array, or other type
|
|
21
|
+
*/
|
|
22
|
+
function fromJson(text, reviver) {
|
|
23
|
+
return JSON.parse(text, reviver);
|
|
24
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const RUNTIME: Runtime;
|
|
5
5
|
export interface Runtime {
|
|
6
|
-
type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown";
|
|
6
|
+
type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd" | "edge-runtime";
|
|
7
7
|
version?: string;
|
|
8
|
+
parsedVersion?: number;
|
|
8
9
|
}
|
|
@@ -1,76 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c, _d;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.RUNTIME = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
7
|
-
*/
|
|
8
|
-
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
9
|
-
/**
|
|
10
|
-
* A constant that indicates whether the environment the code is running is a Web Worker.
|
|
11
|
-
*/
|
|
12
|
-
const isWebWorker = typeof self === "object" &&
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
|
|
15
|
-
(((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" ||
|
|
16
|
-
((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" ||
|
|
17
|
-
((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope");
|
|
18
|
-
/**
|
|
19
|
-
* A constant that indicates whether the environment the code is running is Deno.
|
|
20
|
-
*/
|
|
21
|
-
const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
|
|
22
|
-
/**
|
|
23
|
-
* A constant that indicates whether the environment the code is running is Bun.sh.
|
|
24
|
-
*/
|
|
25
|
-
const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
|
|
26
|
-
/**
|
|
27
|
-
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
28
|
-
*/
|
|
29
|
-
const isNode = typeof process !== "undefined" &&
|
|
30
|
-
Boolean(process.version) &&
|
|
31
|
-
Boolean((_d = process.versions) === null || _d === void 0 ? void 0 : _d.node) &&
|
|
32
|
-
// Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
|
|
33
|
-
!isDeno &&
|
|
34
|
-
!isBun;
|
|
35
|
-
/**
|
|
36
|
-
* A constant that indicates whether the environment the code is running is in React-Native.
|
|
37
|
-
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
38
|
-
*/
|
|
39
|
-
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
40
4
|
/**
|
|
41
5
|
* A constant that indicates which environment and version the SDK is running in.
|
|
42
6
|
*/
|
|
43
7
|
exports.RUNTIME = evaluateRuntime();
|
|
44
8
|
function evaluateRuntime() {
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
10
|
+
/**
|
|
11
|
+
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
12
|
+
*/
|
|
13
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
45
14
|
if (isBrowser) {
|
|
46
15
|
return {
|
|
47
16
|
type: "browser",
|
|
48
17
|
version: window.navigator.userAgent,
|
|
49
18
|
};
|
|
50
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* A constant that indicates whether the environment the code is running is Cloudflare.
|
|
22
|
+
* https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
|
|
23
|
+
*/
|
|
24
|
+
const isCloudflare = typeof globalThis !== "undefined" && ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === "Cloudflare-Workers";
|
|
25
|
+
if (isCloudflare) {
|
|
26
|
+
return {
|
|
27
|
+
type: "workerd",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A constant that indicates whether the environment the code is running is Edge Runtime.
|
|
32
|
+
* https://vercel.com/docs/functions/runtimes/edge-runtime#check-if-you're-running-on-the-edge-runtime
|
|
33
|
+
*/
|
|
34
|
+
const isEdgeRuntime = typeof EdgeRuntime === "string";
|
|
35
|
+
if (isEdgeRuntime) {
|
|
36
|
+
return {
|
|
37
|
+
type: "edge-runtime",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A constant that indicates whether the environment the code is running is a Web Worker.
|
|
42
|
+
*/
|
|
43
|
+
const isWebWorker = typeof self === "object" &&
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
|
|
46
|
+
(((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "DedicatedWorkerGlobalScope" ||
|
|
47
|
+
((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "ServiceWorkerGlobalScope" ||
|
|
48
|
+
((_d = self.constructor) === null || _d === void 0 ? void 0 : _d.name) === "SharedWorkerGlobalScope");
|
|
51
49
|
if (isWebWorker) {
|
|
52
50
|
return {
|
|
53
51
|
type: "web-worker",
|
|
54
52
|
};
|
|
55
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* A constant that indicates whether the environment the code is running is Deno.
|
|
56
|
+
* FYI Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
|
|
57
|
+
*/
|
|
58
|
+
const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
|
|
56
59
|
if (isDeno) {
|
|
57
60
|
return {
|
|
58
61
|
type: "deno",
|
|
59
62
|
version: Deno.version.deno,
|
|
60
63
|
};
|
|
61
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* A constant that indicates whether the environment the code is running is Bun.sh.
|
|
67
|
+
*/
|
|
68
|
+
const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
|
|
62
69
|
if (isBun) {
|
|
63
70
|
return {
|
|
64
71
|
type: "bun",
|
|
65
72
|
version: Bun.version,
|
|
66
73
|
};
|
|
67
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
77
|
+
*/
|
|
78
|
+
const isNode = typeof process !== "undefined" &&
|
|
79
|
+
"version" in process &&
|
|
80
|
+
!!process.version &&
|
|
81
|
+
"versions" in process &&
|
|
82
|
+
!!((_e = process.versions) === null || _e === void 0 ? void 0 : _e.node);
|
|
68
83
|
if (isNode) {
|
|
69
84
|
return {
|
|
70
85
|
type: "node",
|
|
71
86
|
version: process.versions.node,
|
|
87
|
+
parsedVersion: Number(process.versions.node.split(".")[0]),
|
|
72
88
|
};
|
|
73
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* A constant that indicates whether the environment the code is running is in React-Native.
|
|
92
|
+
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
93
|
+
*/
|
|
94
|
+
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
74
95
|
if (isReactNative) {
|
|
75
96
|
return {
|
|
76
97
|
type: "react-native",
|
package/dist/environments.d.ts
CHANGED