telnyx 1.27.0 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/CHANGELOG.md +44 -1
  2. package/LICENSE +1 -1
  3. package/README.md +118 -100
  4. package/VERSION +1 -1
  5. package/dist/telnyx.node.js +3 -0
  6. package/package.json +40 -33
  7. package/src/Error.ts +196 -0
  8. package/src/TelnyxMethod.basic.ts +29 -0
  9. package/{lib/TelnyxMethod.js → src/TelnyxMethod.ts} +37 -18
  10. package/{lib/TelnyxResource.js → src/TelnyxResource.ts} +211 -134
  11. package/src/Types.d.ts +244 -0
  12. package/src/Webhooks.ts +98 -0
  13. package/src/autoPagination.ts +315 -0
  14. package/{lib/makeRequest.js → src/makeRequest.ts} +53 -34
  15. package/src/multipart.ts +99 -0
  16. package/{lib/resources/AI.js → src/resources/AI.ts} +9 -11
  17. package/src/resources/AccessIpAddress.ts +6 -0
  18. package/src/resources/AccessIpRanges.ts +6 -0
  19. package/src/resources/Actions.ts +9 -0
  20. package/{lib/resources/ActionsSimCards.js → src/resources/ActionsSimCards.ts} +3 -5
  21. package/src/resources/ActivateDeactivateBulkCredentials.ts +22 -0
  22. package/{lib/resources/Addresses.js → src/resources/Addresses.ts} +12 -8
  23. package/src/resources/AuthenticationProviders.ts +6 -0
  24. package/src/resources/AutorespConfigs.ts +13 -0
  25. package/src/resources/AvailablePhoneNumbers.ts +6 -0
  26. package/src/resources/Balance.ts +6 -0
  27. package/src/resources/BillingGroups.ts +6 -0
  28. package/src/resources/Brands.ts +68 -0
  29. package/{lib/resources/BulkCredentials.js → src/resources/BulkCredentials.ts} +3 -6
  30. package/{lib/resources/BulkSoleProprietorCreation.js → src/resources/BulkSoleProprietorCreation.ts} +3 -6
  31. package/{lib/resources/BulkTelephonyCredentials.js → src/resources/BulkTelephonyCredentials.ts} +12 -9
  32. package/{lib/resources/BusinessIdentity.js → src/resources/BusinessIdentity.ts} +3 -6
  33. package/{lib/resources/CallControlApplications.js → src/resources/CallControlApplications.ts} +12 -9
  34. package/src/resources/CallEvents.ts +6 -0
  35. package/{lib/resources/CallInformation.js → src/resources/CallInformation.ts} +3 -6
  36. package/{lib/resources/CallRecordings.js → src/resources/CallRecordings.ts} +2 -5
  37. package/src/resources/Calls.ts +94 -0
  38. package/{lib/resources/Campaign.js → src/resources/Campaign.ts} +11 -8
  39. package/{lib/resources/CampaignBuilder.js → src/resources/CampaignBuilder.ts} +11 -8
  40. package/{lib/resources/CdrUsageReports.js → src/resources/CdrUsageReports.ts} +3 -6
  41. package/{lib/resources/Channelzones.js → src/resources/Channelzones.ts} +3 -6
  42. package/src/resources/ClientStateUpdate.ts +6 -0
  43. package/{lib/resources/Conferences.js → src/resources/Conferences.ts} +21 -16
  44. package/src/resources/Connections.ts +6 -0
  45. package/src/resources/CredentialConnections.ts +6 -0
  46. package/{lib/resources/Credentials.js → src/resources/Credentials.ts} +3 -6
  47. package/{lib/resources/CsvDownloads.js → src/resources/CsvDownloads.ts} +3 -6
  48. package/{lib/resources/CustomerServiceRecord.js → src/resources/CustomerServiceRecord.ts} +3 -6
  49. package/{lib/resources/Debugging.js → src/resources/Debugging.ts} +3 -6
  50. package/src/resources/DetailRecords.ts +11 -0
  51. package/{lib/resources/DialogflowIntegration.js → src/resources/DialogflowIntegration.ts} +2 -5
  52. package/src/resources/DocumentLinks.ts +6 -0
  53. package/{lib/resources/Documents.js → src/resources/Documents.ts} +9 -6
  54. package/src/resources/DynamicEmergency.ts +10 -0
  55. package/src/resources/DynamicEmergencyAddresses.ts +6 -0
  56. package/src/resources/DynamicEmergencyEndpoints.ts +6 -0
  57. package/src/resources/Events.ts +6 -0
  58. package/{lib/resources/ExternalConnections.js → src/resources/ExternalConnections.ts} +3 -6
  59. package/src/resources/FaxApplications.ts +53 -0
  60. package/src/resources/Faxes.ts +51 -0
  61. package/src/resources/FqdnConnections.ts +53 -0
  62. package/src/resources/Fqdns.ts +53 -0
  63. package/{lib/resources/GlobalIps.js → src/resources/GlobalIps.ts} +3 -6
  64. package/{lib/resources/InboundChannels.js → src/resources/InboundChannels.ts} +3 -6
  65. package/src/resources/InventoryCoverage.ts +11 -0
  66. package/{lib/resources/InventoryLevel.js → src/resources/InventoryLevel.ts} +3 -6
  67. package/{lib/resources/IpAddresses.js → src/resources/IpAddresses.ts} +3 -6
  68. package/src/resources/IpConnections.ts +53 -0
  69. package/{lib/resources/IpRanges.js → src/resources/IpRanges.ts} +3 -6
  70. package/src/resources/Ips.ts +53 -0
  71. package/{lib/resources/ManagedAccounts.js → src/resources/ManagedAccounts.ts} +10 -7
  72. package/{lib/resources/MdrDetailReports.js → src/resources/MdrDetailReports.ts} +3 -6
  73. package/{lib/resources/MdrUsageReports.js → src/resources/MdrUsageReports.ts} +3 -6
  74. package/{lib/resources/MediaStorageApi.js → src/resources/MediaStorageApi.ts} +3 -6
  75. package/src/resources/Messages.ts +11 -0
  76. package/src/resources/MessagesAlphanumericSenderId.ts +6 -0
  77. package/{lib/resources/MessagingHostedNumber.js → src/resources/MessagingHostedNumber.ts} +3 -6
  78. package/src/resources/MessagingHostedNumberOrders.ts +6 -0
  79. package/src/resources/MessagingHostedNumbers.ts +6 -0
  80. package/src/resources/MessagingPhoneNumbers.ts +6 -0
  81. package/src/resources/MessagingProfileMetrics.ts +6 -0
  82. package/{lib/resources/MessagingProfiles.js → src/resources/MessagingProfiles.ts} +27 -27
  83. package/src/resources/MessagingSenderIds.ts +6 -0
  84. package/src/resources/MessagingShortCodes.ts +6 -0
  85. package/{lib/resources/MessagingTollfreeVerification.js → src/resources/MessagingTollfreeVerification.ts} +3 -6
  86. package/{lib/resources/MessagingUrlDomains.js → src/resources/MessagingUrlDomains.ts} +3 -6
  87. package/{lib/resources/MobileNetworkOperators.js → src/resources/MobileNetworkOperators.ts} +3 -6
  88. package/src/resources/MobileOperatorNetworks.ts +6 -0
  89. package/{lib/resources/Networks.js → src/resources/Networks.ts} +3 -6
  90. package/src/resources/NumberBackgroundJobs.ts +22 -0
  91. package/src/resources/NumberLookup.ts +6 -0
  92. package/{lib/resources/NumberOrderDocuments.js → src/resources/NumberOrderDocuments.ts} +3 -6
  93. package/src/resources/NumberOrders.ts +6 -0
  94. package/{lib/resources/NumberPortouts.js → src/resources/NumberPortouts.ts} +11 -8
  95. package/{lib/resources/NumberReservations.js → src/resources/NumberReservations.ts} +8 -11
  96. package/{lib/resources/NumbersFeatures.js → src/resources/NumbersFeatures.ts} +2 -5
  97. package/{lib/resources/Object.js → src/resources/Object.ts} +2 -5
  98. package/{lib/resources/OtaUpdates.js → src/resources/OtaUpdates.ts} +3 -6
  99. package/{lib/resources/Outbound.js → src/resources/OutboundVoiceProfiles.ts} +17 -9
  100. package/src/resources/Payment.ts +16 -0
  101. package/{lib/resources/PhoneNumberAssignmentByProfile.js → src/resources/PhoneNumberAssignmentByProfile.ts} +28 -9
  102. package/{lib/resources/PhoneNumberBlockOrders.js → src/resources/PhoneNumberBlockOrders.ts} +3 -6
  103. package/{lib/resources/PhoneNumberBlocksBackgroundJobs.js → src/resources/PhoneNumberBlocksBackgroundJobs.ts} +3 -6
  104. package/{lib/resources/PhoneNumberCampaigns.js → src/resources/PhoneNumberCampaigns.ts} +3 -5
  105. package/{lib/resources/PhoneNumberOrderDocuments.js → src/resources/PhoneNumberOrderDocuments.ts} +3 -6
  106. package/src/resources/PhoneNumberRegulatoryRequirements.ts +7 -0
  107. package/{lib/resources/PhoneNumberSearch.js → src/resources/PhoneNumberSearch.ts} +3 -6
  108. package/{lib/resources/PhoneNumbers.js → src/resources/PhoneNumbers.ts} +9 -8
  109. package/{lib/resources/PhoneNumbersInboundChannels.js → src/resources/PhoneNumbersInboundChannels.ts} +11 -8
  110. package/src/resources/PhoneNumbersMessaging.ts +6 -0
  111. package/src/resources/PhoneNumbersVoice.ts +6 -0
  112. package/src/resources/PortabilityChecks.ts +10 -0
  113. package/{lib/resources/PortingOrders.js → src/resources/PortingOrders.ts} +34 -36
  114. package/src/resources/PortingPhoneNumbers.ts +6 -0
  115. package/{lib/resources/PortoutRequests.js → src/resources/PortoutRequests.ts} +3 -5
  116. package/{lib/resources/PresignedObjectUrls.js → src/resources/PresignedObjectUrls.ts} +2 -5
  117. package/{lib/resources/PrivateWirelessGateways.js → src/resources/PrivateWirelessGateways.ts} +3 -6
  118. package/{lib/resources/PublicInternetGateways.js → src/resources/PublicInternetGateways.ts} +3 -6
  119. package/src/resources/PublicKey.ts +10 -0
  120. package/{lib/resources/PushCredentials.js → src/resources/PushCredentials.ts} +3 -6
  121. package/src/resources/Queues.ts +68 -0
  122. package/{lib/resources/RecordingsCommands.js → src/resources/RecordingsCommands.ts} +3 -6
  123. package/src/resources/Regions.ts +12 -0
  124. package/src/resources/RegulatoryRequirements.ts +7 -0
  125. package/{lib/resources/Reporting.js → src/resources/Reporting.ts} +3 -6
  126. package/{lib/resources/Reports.js → src/resources/Reports.ts} +3 -6
  127. package/src/resources/ReportsMdrs.ts +6 -0
  128. package/{lib/resources/RequirementTypes.js → src/resources/RequirementTypes.ts} +3 -6
  129. package/{lib/resources/Requirements.js → src/resources/Requirements.ts} +3 -6
  130. package/src/resources/RoomCompositions.ts +6 -0
  131. package/src/resources/RoomParticipants.ts +6 -0
  132. package/{lib/resources/RoomRecordings.js → src/resources/RoomRecordings.ts} +2 -5
  133. package/{lib/resources/RoomSessions.js → src/resources/RoomSessions.ts} +3 -5
  134. package/src/resources/Rooms.ts +6 -0
  135. package/{lib/resources/RoomsClientToken.js → src/resources/RoomsClientToken.ts} +3 -5
  136. package/{lib/resources/RoomsClientTokens.js → src/resources/RoomsClientTokens.ts} +4 -7
  137. package/{lib/resources/SharedCampaigns.js → src/resources/SharedCampaigns.ts} +3 -6
  138. package/src/resources/ShortCodes.ts +37 -0
  139. package/{lib/resources/SimCardActions.js → src/resources/SimCardActions.ts} +3 -6
  140. package/{lib/resources/SimCardGroupActions.js → src/resources/SimCardGroupActions.ts} +3 -6
  141. package/src/resources/SimCardGroups.ts +53 -0
  142. package/src/resources/SimCardOrders.ts +6 -0
  143. package/{lib/resources/SimCards.js → src/resources/SimCards.ts} +20 -33
  144. package/src/resources/StorageBuckets.ts +36 -0
  145. package/{lib/resources/TelephonyCredentials.js → src/resources/TelephonyCredentials.ts} +14 -12
  146. package/src/resources/TexmlApplications.ts +6 -0
  147. package/src/resources/UpdateClientState.ts +25 -0
  148. package/{lib/resources/Verifications.js → src/resources/Verifications.ts} +12 -10
  149. package/src/resources/VerifiedNumbers.ts +6 -0
  150. package/{lib/resources/Verify.js → src/resources/Verify.ts} +3 -6
  151. package/{lib/resources/VerifyProfiles.js → src/resources/VerifyProfiles.ts} +9 -8
  152. package/{lib/resources/VirtualCrossConnects.js → src/resources/VirtualCrossConnects.ts} +3 -6
  153. package/{lib/resources/WdrDetailReports.js → src/resources/WdrDetailReports.ts} +3 -6
  154. package/src/resources/Webhooks.ts +6 -0
  155. package/{lib/resources/WireguardInterfaces.js → src/resources/WireguardInterfaces.ts} +3 -6
  156. package/src/resources/WirelessDetailRecordReports.ts +6 -0
  157. package/src/telnyx.node.ts +5 -0
  158. package/src/telnyx.ts +636 -0
  159. package/src/utils.ts +383 -0
  160. package/types/AccessIpAddressResource.d.ts +57 -0
  161. package/types/AccessIpRangesResource.d.ts +43 -0
  162. package/types/AddressesResource.d.ts +78 -0
  163. package/types/AutorespConfigsResource.d.ts +74 -0
  164. package/types/AvailablePhoneNumbersResource.d.ts +18 -0
  165. package/types/BalanceResource.d.ts +19 -0
  166. package/types/BillingGroupsResource.d.ts +72 -0
  167. package/types/BrandsResource.d.ts +142 -0
  168. package/types/CallsResource.d.ts +299 -0
  169. package/types/Errors.d.ts +131 -0
  170. package/types/MessagingProfileMetricsResource.d.ts +18 -0
  171. package/types/MessagingProfilesResource.d.ts +132 -0
  172. package/types/PhoneNumberAssignmentByProfileResource.d.ts +53 -0
  173. package/types/StorageBucketsResource.d.ts +74 -0
  174. package/types/TelnyxAPI.d.ts +65420 -0
  175. package/types/Webhooks.d.ts +26 -0
  176. package/types/index.d.ts +60 -0
  177. package/types/lib.d.ts +44 -0
  178. package/lib/Error.js +0 -143
  179. package/lib/MultipartDataGenerator.js +0 -45
  180. package/lib/TelnyxMethod.basic.js +0 -112
  181. package/lib/Webhooks.js +0 -72
  182. package/lib/autoPagination.js +0 -231
  183. package/lib/resources/AccessIpAddress.js +0 -6
  184. package/lib/resources/AccessIpRanges.js +0 -6
  185. package/lib/resources/AccessTokens.js +0 -6
  186. package/lib/resources/Actions.js +0 -9
  187. package/lib/resources/ActivateDeactivateBulkCredentials.js +0 -20
  188. package/lib/resources/AdvancedOptinoptout.js +0 -21
  189. package/lib/resources/AuthenticationProviders.js +0 -8
  190. package/lib/resources/Autorechargepreferences.js +0 -15
  191. package/lib/resources/AvailablePhoneNumbers.js +0 -7
  192. package/lib/resources/Balance.js +0 -11
  193. package/lib/resources/Billing.js +0 -15
  194. package/lib/resources/BillingGroups.js +0 -6
  195. package/lib/resources/Brands.js +0 -36
  196. package/lib/resources/Bucket.js +0 -16
  197. package/lib/resources/BucketUsage.js +0 -21
  198. package/lib/resources/BulkCreation.js +0 -52
  199. package/lib/resources/BulkPhoneNumberCampaigns.js +0 -25
  200. package/lib/resources/BulkPhoneNumberOperations.js +0 -32
  201. package/lib/resources/CallEvents.js +0 -7
  202. package/lib/resources/Calls.js +0 -73
  203. package/lib/resources/ClientStateUpdate.js +0 -6
  204. package/lib/resources/Connections.js +0 -8
  205. package/lib/resources/CredentialConnections.js +0 -6
  206. package/lib/resources/DetailRecords.js +0 -13
  207. package/lib/resources/DocumentLinks.js +0 -6
  208. package/lib/resources/DynamicEmergency.js +0 -10
  209. package/lib/resources/DynamicEmergencyAddresses.js +0 -8
  210. package/lib/resources/DynamicEmergencyEndpoints.js +0 -8
  211. package/lib/resources/Events.js +0 -7
  212. package/lib/resources/FaxApplications.js +0 -55
  213. package/lib/resources/Faxes.js +0 -53
  214. package/lib/resources/FqdnConnections.js +0 -55
  215. package/lib/resources/Fqdns.js +0 -55
  216. package/lib/resources/InventoryCoverage.js +0 -13
  217. package/lib/resources/IpConnections.js +0 -55
  218. package/lib/resources/Ips.js +0 -55
  219. package/lib/resources/Messages.js +0 -10
  220. package/lib/resources/MessagesAlphanumericSenderId.js +0 -6
  221. package/lib/resources/MessagingHostedNumberOrders.js +0 -6
  222. package/lib/resources/MessagingHostedNumbers.js +0 -6
  223. package/lib/resources/MessagingPhoneNumbers.js +0 -7
  224. package/lib/resources/MessagingProfileMetrics.js +0 -7
  225. package/lib/resources/MessagingSenderIds.js +0 -7
  226. package/lib/resources/MessagingShortCodes.js +0 -7
  227. package/lib/resources/MobileOperatorNetworks.js +0 -8
  228. package/lib/resources/NumberBackgroundJobs.js +0 -24
  229. package/lib/resources/NumberLookup.js +0 -8
  230. package/lib/resources/NumberOrders.js +0 -7
  231. package/lib/resources/OutboundVoiceProfiles.js +0 -19
  232. package/lib/resources/PhoneNumberRegulatoryRequirements.js +0 -9
  233. package/lib/resources/PhoneNumbersMessaging.js +0 -6
  234. package/lib/resources/PhoneNumbersVoice.js +0 -6
  235. package/lib/resources/PortabilityChecks.js +0 -12
  236. package/lib/resources/PortingPhoneNumbers.js +0 -8
  237. package/lib/resources/PublicKey.js +0 -13
  238. package/lib/resources/Queues.js +0 -41
  239. package/lib/resources/Regions.js +0 -15
  240. package/lib/resources/RegisterCall.js +0 -6
  241. package/lib/resources/RegulatoryRequirements.js +0 -9
  242. package/lib/resources/ReportsMdrs.js +0 -6
  243. package/lib/resources/RoomCompositions.js +0 -8
  244. package/lib/resources/RoomParticipants.js +0 -8
  245. package/lib/resources/Rooms.js +0 -6
  246. package/lib/resources/ShortCodes.js +0 -39
  247. package/lib/resources/SimCardGroups.js +0 -55
  248. package/lib/resources/SimCardOrders.js +0 -6
  249. package/lib/resources/SslCertificates.js +0 -20
  250. package/lib/resources/TeXMLApplication.js +0 -6
  251. package/lib/resources/UpdateClientState.js +0 -22
  252. package/lib/resources/VerifiedCallsDisplayProfile.js +0 -25
  253. package/lib/resources/VerifiedCallsDisplayProfiles.js +0 -13
  254. package/lib/resources/VerifiedNumbers.js +0 -6
  255. package/lib/resources/Webhooks.js +0 -6
  256. package/lib/resources/WirelessDetailRecordReports.js +0 -8
  257. package/lib/telnyx.js +0 -425
  258. package/lib/utils.js +0 -366
package/CHANGELOG.md CHANGED
@@ -1,23 +1,66 @@
1
1
  # CHANGELOG
2
2
 
3
- ##
3
+ ## v2
4
+
5
+ ### v2.0.0-alpha.0
6
+
7
+ - Add Typescript default config, linter and dependencies
8
+ - Bump default Node version to `20`
9
+ - Update README on [Development](./README.md#development) instructions
10
+ - Remove `yarn` in favor of `npm` 10
11
+ - Convert SDK files to Typescript
12
+ - Convert Resources to Typescript
13
+ - Use ES Modules syntax
14
+ - Update package `main` entrypoint to be compiled version of [src telnyx.ts](./src/telnyx.ts)
15
+ - Added `Jest` and create tests in Typescript
16
+ - Update tests expect matchers according to limitations with `prism mock`
17
+ - Add `nock` cleanup setup
18
+ - Make `setApiKey` TelnyxObject prototype method private
19
+ - Moved to `moduleResolution` Bundler to support better imports and tests with `Jest`
20
+ - Enabled `esModuleInterop` for Jest
21
+ - Update files included when publishing
22
+ - Remove custom resource get `generateAccessTokenFromCredential` from `TelephonyCredentials`
23
+ - Update `AutoRechargePreferences` resource
24
+ - Remove `RegisterCall` resource
25
+ - Remove `ProgrammableFaxCommants` specs
26
+ - Remove `BulkCreation` resource
27
+ - Update `TexmlApplications` resource
28
+ - Remove `Conferences` `dial_participant` action
29
+ - Remove `SimCards` `deletePublicIp` and `setPublicIp`
30
+ - Update `Queues` method names to camelCase
31
+ - Remove `VerifiedCallsDisplayProfile` resource
32
+ - Update examples to Typescript
33
+ - Remove duplicated `AccessTokens` resource
34
+ - Move custom `AdvancedOptinoptout` resource to be `AutoRespConfigs` resource
35
+ - Remove `Billing` resource
36
+ - Remove inexistent `Bucket` resource
37
+ - Move `BucketUsage` resource to `StorageBuckets`
38
+ - Remove duplicated `BulkPhoneNumberCampaigns` resource
39
+ - Remove duplicated `BulkPhoneNumberOperations` resource
40
+
41
+ ## v1
4
42
 
5
43
  ### v1.26.2
44
+
6
45
  - Fix Brand and Campaign redirects
7
46
  - Update security
8
47
 
9
48
  ### v1.26.1
49
+
10
50
  - Fix porting comments
11
51
 
12
52
  ### v1.26.0
53
+
13
54
  - Endpoint additions
14
55
  - Package upgrades
15
56
  - Preparation for typescript migration/support
16
57
 
17
58
  ### v1.25.5
59
+
18
60
  - Security Updates + API Additions
19
61
 
20
62
  ### v1.23.0 (2021-10-19)
63
+
21
64
  - **Addresses** added `validate`
22
65
  - **AuthenticationProvider** added `list`, `create`, `retrieve`, `update`, `del`
23
66
  - **DynamicEmergency** (for `endpoints` and `addresses`) added `list`, `retrieve`, `create`, `del`
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Copyright (C) 2011 Ask Bjørn Hansen
2
2
  Copyright (C) 2013 Stripe, Inc. (https://stripe.com)
3
- Copyright (C) 2019 Telnyx, Inc. (https://www.telnyx.com)
3
+ Copyright (C) 2019 Telnyx, Inc. (https://telnyx.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Version](https://img.shields.io/npm/v/telnyx.svg)](https://www.npmjs.org/package/telnyx)
4
4
  [![Build Status](https://github.com/team-telnyx/telnyx-node/workflows/CI/badge.svg)](https://github.com/team-telnyx/telnyx-node/actions)
5
- [![Coverage Status](https://coveralls.io/repos/github/team-telnyx/telnyx-node/badge.svg?branch=master)](https://coveralls.io/github/team-telnyx/telnyx-node?branch=master)
5
+ Coverage Status: Pending
6
6
  [![Downloads](https://img.shields.io/npm/dm/telnyx.svg)](https://www.npmjs.com/package/telnyx)
7
7
  [![Try on RunKit](https://badge.runkitcdn.com/telnyx.svg)](https://runkit.com/npm/telnyx)
8
8
  [![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://joinslack.telnyx.com/)
@@ -26,62 +26,41 @@ The package needs to be configured with your account's API key which is
26
26
  available in your the [Telnyx Mission Control Portal][api-keys]. Require it with the key's
27
27
  value:
28
28
 
29
- ``` js
30
- const telnyx = require('telnyx')('KEY123456...');
29
+ ```typescript
30
+ import Telnyx from 'telnyx';
31
+
32
+ const telnyx = new Telnyx('KEY123456...');
31
33
 
32
34
  const messagingProfile = await telnyx.messagingProfiles.create({
33
- name: 'Summer Campaign'
35
+ name: 'Summer Campaign',
34
36
  });
35
37
  ```
36
38
 
37
- Or with versions of Node.js prior to v7.9:
38
-
39
- ``` js
40
- var telnyx = require('telnyx')('KEY123456...');
41
-
42
- telnyx.messagingProfiles.create(
43
- { name: 'Summer Campaign' },
44
- function(err, messagingProfile) {
45
- err; // null if no error occurred
46
- messagingProfile; // the created messaging profile object
47
- }
48
- );
49
- ```
50
-
51
- Or using ES modules, this looks more like:
52
-
53
- ```js
54
- import Telnyx from 'telnyx';
55
- const telnyx = Telnyx('KEY...');
56
- //…
57
- ```
58
-
59
39
  ### Using Promises
60
40
 
61
41
  Every method returns a chainable promise which can be used instead of a regular
62
42
  callback:
63
43
 
64
- ```js
44
+ ```typescript
65
45
  // Create a new messaging profile and then send a message using that profile:
66
- telnyx.MessagingProfiles.create({
67
- name: 'Summer Campaign'
68
- }).then((messagingProfile) => {
69
- return telnyx.MessagingPhoneNumbers.update(
70
- '+18005554000',
71
- {
72
- 'messaging_profile_id': messagingProfile.data.id
73
- }
74
- );
75
- }).catch((err) => {
76
- // Deal with an error
77
- });
46
+ telnyx.,essagingProfiles.create({
47
+ name: 'Summer Campaign',
48
+ })
49
+ .then((messagingProfile) => {
50
+ return telnyx.messagingPhoneNumbers.update('+18005554000', {
51
+ messaging_profile_id: messagingProfile.data.id,
52
+ });
53
+ })
54
+ .catch((err) => {
55
+ // Deal with an error
56
+ });
78
57
  ```
79
58
 
80
59
  ### Configuring Timeout
81
60
 
82
61
  Request timeout is configurable (the default is Node's default of 120 seconds):
83
62
 
84
- ``` js
63
+ ```typescript
85
64
  telnyx.setTimeout(20000); // in ms (this is 20 seconds)
86
65
  ```
87
66
 
@@ -90,11 +69,12 @@ telnyx.setTimeout(20000); // in ms (this is 20 seconds)
90
69
  An [https-proxy-agent][https-proxy-agent] can be configured with
91
70
  `setHttpAgent`.
92
71
 
93
- To use telnyx behind a proxy you can pass to sdk:
72
+ To use telnyx behind a proxy you can pass to sdk:
73
+
74
+ ```typescript
75
+ import ProxyAgent from 'https-proxy-agent';
94
76
 
95
- ```js
96
77
  if (process.env.http_proxy) {
97
- const ProxyAgent = require('https-proxy-agent');
98
78
  telnyx.setHttpAgent(new ProxyAgent(process.env.http_proxy));
99
79
  }
100
80
  ```
@@ -105,7 +85,7 @@ Automatic network retries can be enabled with `setMaxNetworkRetries`. This will
105
85
  retry requests `n` times with exponential backoff if they fail due to an
106
86
  intermittent network problem.
107
87
 
108
- ```js
88
+ ```typescript
109
89
  // Retry a request once before giving up
110
90
  telnyx.setMaxNetworkRetries(1);
111
91
  ```
@@ -115,21 +95,23 @@ telnyx.setMaxNetworkRetries(1);
115
95
  Some information about the response which generated a resource is available
116
96
  with the `lastResponse` property:
117
97
 
118
- ```js
119
- messagingProfile.lastResponse.requestId // see: https://telnyx.com/docs/api/node#request_ids
120
- messagingProfile.lastResponse.statusCode
98
+ ```typescript
99
+ messagingProfile.lastResponse.requestId; // see: https://telnyx.com/docs/api/node#request_ids
100
+ messagingProfile.lastResponse.statusCode;
121
101
  ```
122
102
 
123
103
  ### `request` and `response` events
124
104
 
125
- The Telnyx object emits `request` and `response` events. You can use them like this:
105
+ The Telnyx object emits `request` and `response` events. You can use them like this:
106
+
107
+ ```typescript
108
+ import Telnyx from 'telnyx';
126
109
 
127
- ```js
128
- const telnyx = require('telnyx')('KEY...');
110
+ const telnyx = new Telnyx('KEY...');
129
111
 
130
112
  const onRequest = (request) => {
131
113
  // Do something.
132
- }
114
+ };
133
115
 
134
116
  // Add the event handler function:
135
117
  telnyx.on('request', onRequest);
@@ -139,7 +121,8 @@ telnyx.off('request', onRequest);
139
121
  ```
140
122
 
141
123
  #### `request` object
142
- ```js
124
+
125
+ ```typescript
143
126
  {
144
127
  method: 'POST',
145
128
  path: '/v2/messaging_profiles'
@@ -147,7 +130,8 @@ telnyx.off('request', onRequest);
147
130
  ```
148
131
 
149
132
  #### `response` object
150
- ```js
133
+
134
+ ```typescript
151
135
  {
152
136
  method: 'POST',
153
137
  path: '/v2/messaging_profiles',
@@ -171,12 +155,12 @@ You can find an example of how to use this with [Express](https://expressjs.com/
171
155
  in the [`examples/webhook-signing`](examples/webhook-signing) folder, but here's
172
156
  what it looks like:
173
157
 
174
- ```js
158
+ ```typescript
175
159
  const event = telnyx.webhooks.constructEvent(
176
160
  webhookRawBody,
177
161
  webhookTelnyxSignatureHeader,
178
162
  webhookTelnyxTimestampHeader,
179
- publicKey
163
+ publicKey,
180
164
  );
181
165
  ```
182
166
 
@@ -186,7 +170,7 @@ TeXML sends webhooks as form-encoded payloads instead of JSON. To validate the s
186
170
 
187
171
  You can find an example of how to use this with [Express](https://expressjs.com/) in the [`examples/webhook-signing`](examples/webhook-signing) folder.
188
172
 
189
- ```js
173
+ ```typescript
190
174
  const timeToleranceInSeconds = 300; // Will validate signatures of webhooks up to 5 minutes after Telnyx sent the request
191
175
  try {
192
176
  telnyx.webhooks.signature.verifySignature(
@@ -194,20 +178,19 @@ try {
194
178
  webhookTelnyxSignatureHeader,
195
179
  webhookTelnyxTimestampHeader,
196
180
  publicKey,
197
- timeToleranceInSeconds
181
+ timeToleranceInSeconds,
198
182
  );
199
183
  } catch (e) {
200
- console.log("Failed to validate the signature")
184
+ console.log('Failed to validate the signature');
201
185
  console.log(e);
202
186
  }
203
-
204
187
  ```
205
188
 
206
189
  ### Writing a Plugin
207
190
 
208
191
  If you're writing a plugin that uses the library, we'd appreciate it if you identified using `telnyx.setAppInfo()`:
209
192
 
210
- ```js
193
+ ```typescript
211
194
  telnyx.setAppInfo({
212
195
  name: 'MyAwesomePlugin',
213
196
  version: '1.2.34', // Optional
@@ -222,14 +205,13 @@ This information is passed along when the library makes calls to the Telnyx API.
222
205
  You can auto-paginate list methods. We provide a few different APIs for this to
223
206
  aid with a variety of node versions and styles.
224
207
 
225
-
226
208
  #### Async iterators (`for-await-of`)
227
209
 
228
210
  If you are in a Node environment that has support for [async iteration](https://github.com/tc39/proposal-async-iteration#the-async-iteration-statement-for-await-of),
229
211
  such as Node 10+ or [babel](https://babeljs.io/docs/en/babel-plugin-transform-async-generator-functions),
230
212
  the following will auto-paginate:
231
213
 
232
- ```js
214
+ ```typescript
233
215
  for await (const messagingProfile of telnyx.messagingProfiles.list()) {
234
216
  doSomething(messagingProfile);
235
217
  if (shouldStop()) {
@@ -243,36 +225,42 @@ for await (const messagingProfile of telnyx.messagingProfiles.list()) {
243
225
  If you are in a Node environment that has support for `await`, such as Node 7.9 and greater,
244
226
  you may pass an async function to `.autoPagingEach`:
245
227
 
246
- ```js
247
- await telnyx.messagingProfiles.list().autoPagingEach(async (messagingProfile) => {
248
- await doSomething(messagingProfile);
249
- if (shouldBreak()) {
250
- return false;
251
- }
252
- })
228
+ ```typescript
229
+ await telnyx.messagingProfiles
230
+ .list()
231
+ .autoPagingEach(async (messagingProfile) => {
232
+ await doSomething(messagingProfile);
233
+ if (shouldBreak()) {
234
+ return false;
235
+ }
236
+ });
253
237
  console.log('Done iterating.');
254
238
  ```
255
239
 
256
240
  Equivalently, without `await`, you may return a Promise, which can resolve to `false` to break:
257
241
 
258
- ```js
259
- telnyx.messagingProfiles.list().autoPagingEach((messagingProfile) => {
260
- return doSomething(messagingProfile).then(() => {
261
- if (shouldBreak()) {
262
- return false;
263
- }
264
- });
265
- }).then(() => {
266
- console.log('Done iterating.');
267
- }).catch(handleError);
242
+ ```typescript
243
+ telnyx.messagingProfiles
244
+ .list()
245
+ .autoPagingEach((messagingProfile) => {
246
+ return doSomething(messagingProfile).then(() => {
247
+ if (shouldBreak()) {
248
+ return false;
249
+ }
250
+ });
251
+ })
252
+ .then(() => {
253
+ console.log('Done iterating.');
254
+ })
255
+ .catch(handleError);
268
256
  ```
269
257
 
270
258
  If you prefer callbacks to promises, you may also use a `next` callback and a second `onDone` callback:
271
259
 
272
- ```js
260
+ ```typescript
273
261
  telnyx.messagingProfiles.list().autoPagingEach(
274
262
  function onItem(messagingProfile, next) {
275
- doSomething(messagingProfile, function(err, result) {
263
+ doSomething(messagingProfile, function (err, result) {
276
264
  if (shouldStop(result)) {
277
265
  next(false); // Passing `false` breaks out of the loop.
278
266
  } else {
@@ -286,8 +274,8 @@ telnyx.messagingProfiles.list().autoPagingEach(
286
274
  } else {
287
275
  console.log('Done iterating.');
288
276
  }
289
- }
290
- )
277
+ },
278
+ );
291
279
  ```
292
280
 
293
281
  If your `onItem` function does not accept a `next` callback parameter _or_ return a Promise,
@@ -301,31 +289,41 @@ to prevent runaway list growth from consuming too much memory.
301
289
 
302
290
  Returns a promise of an array of all items across pages for a list request.
303
291
 
304
- ```js
305
- const allMessagingProfiles = await telnyx.messagingProfiles.list()
292
+ ```typescript
293
+ const allMessagingProfiles = await telnyx.messagingProfiles
294
+ .list()
306
295
  .autoPagingToArray({limit: 10000});
307
296
  ```
308
297
 
309
298
  ## Development
310
299
 
311
300
  ### Setup
312
- The test suite depends on the [Prism Mock Server](https://github.com/stoplightio/prism).
301
+
302
+ Run the following to create your env file
313
303
 
314
304
  ```bash
315
- npm install -g @stoplight/prism-cli
305
+ cp .env.local .env
306
+ ```
307
+
308
+ > Don't forget to update your `.env` values accordingly.
316
309
 
317
- # OR
310
+ Now inject envs into terminal:
318
311
 
319
- yarn global add @stoplight/prism-cli
312
+ ```bash
313
+ . ./setup_env.sh
320
314
  ```
321
315
 
322
- Once installed, start the prism mock service with the following command:
316
+ > Feel free to use Node `--env-file` parameter to [setup envs](https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs) if you prefer
317
+
318
+ The test suite depends on the [Prism Mock Server](https://github.com/stoplightio/prism).
319
+
320
+ Start the prism mock service with the following command:
323
321
 
324
322
  ```bash
325
- prism mock https://raw.githubusercontent.com/team-telnyx/openapi/master/openapi/spec3.json
323
+ npx prism mock https://raw.githubusercontent.com/team-telnyx/openapi/master/openapi/spec3.json
326
324
  ```
327
325
 
328
- --------
326
+ ---
329
327
 
330
328
  One final step -- because the Node SDK originally expected to reach the legacy `telnyx-mock` service at port 12111 (in addition to providing a `/v2/` base path), we need to setup the [Telnyx mock proxy server](https://github.com/team-telnyx/telnyx-mock-server-proxy) to modify the request path and forward along to the prism mock server.
331
329
 
@@ -335,7 +333,7 @@ One final step -- because the Node SDK originally expected to reach the legacy `
335
333
  git clone git@github.com:team-telnyx/telnyx-prism-mock.git
336
334
  cd telnyx-prism-mock/proxy
337
335
 
338
- yarn install
336
+ npm install
339
337
  node index.js
340
338
  ```
341
339
 
@@ -349,22 +347,22 @@ $ npm test
349
347
  Run all tests with a custom `telnyx-mock` port:
350
348
 
351
349
  ```bash
352
- $ TELNYX_MOCK_PORT=12000 npm test
350
+ $ TELNYX_MOCK_PORT=12111 npm test
353
351
  ```
354
352
 
355
353
  Run a single test suite:
356
354
 
357
355
  ```bash
358
- $ npm run mocha -- test/Error.spec.js
356
+ $ npm test -- test/Error.test.ts
359
357
  ```
360
358
 
361
359
  Run a single test (case sensitive):
362
360
 
363
361
  ```bash
364
- $ npm run mocha -- test/Error.spec.js --grep 'Populates with type'
362
+ $ npm test -- test/Error.test.ts -t 'Populates with type'
365
363
  ```
366
364
 
367
- If you wish, you may run tests using your Telnyx *Test* API key by setting the
365
+ If you wish, you may run tests using your Telnyx _Test_ API key by setting the
368
366
  environment variable `TELNYX_TEST_API_KEY` before running the tests:
369
367
 
370
368
  ```bash
@@ -377,10 +375,12 @@ $ npm test
377
375
 
378
376
  To inspect values in tests first import debug:
379
377
 
380
- ```js
381
- var debug = require('debug')('foo');
378
+ ```typescript
379
+ import Debug from 'debug';
380
+
381
+ const debug = Debug('foo');
382
382
  //...
383
- debug(result)
383
+ debug(result);
384
384
  ```
385
385
 
386
386
  Then run the tests with:
@@ -395,6 +395,24 @@ To view verbose debugging for `nock` run the tests with:
395
395
  $ DEBUG=nock.* npm test
396
396
  ```
397
397
 
398
+ ### Typescript
399
+
400
+ Run:
401
+
402
+ ```bash
403
+ npm run build
404
+ ```
405
+
406
+ Then check output in [dist](./dist) folder
407
+
408
+ ### Linter (Prettier)
409
+
410
+ Add an [editor integration](https://prettier.io/docs/en/editors.html) or:
411
+
412
+ ```bash
413
+ $ npm run fix
414
+ ```
415
+
398
416
  ## Acknowledgements
399
417
 
400
418
  The contributors and maintainers of Telnyx Node would like to extend their deep gratitude to the
package/VERSION CHANGED
@@ -1 +1 @@
1
- 1.27.0
1
+ 2.0.0-alpha.0
@@ -0,0 +1,3 @@
1
+ import { createTelnyx } from './telnyx';
2
+ export const Telnyx = createTelnyx();
3
+ export default Telnyx;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telnyx",
3
- "version": "1.27.0",
3
+ "version": "2.0.0-alpha.0",
4
4
  "description": "Telnyx API Node SDK",
5
5
  "keywords": [
6
6
  "telnyx",
@@ -11,57 +11,64 @@
11
11
  "sdk"
12
12
  ],
13
13
  "homepage": "https://developers.telnyx.com",
14
- "author": "Telnyx <support@telnyx.com> (https://www.telnyx.com/)",
14
+ "author": "Telnyx <support@telnyx.com> (https://telnyx.com)",
15
15
  "contributors": [
16
- "Vlad Ionash <vladi@telnyx.com> (http://www.telnyx.com/)",
17
- "Gabriel Taylor Russ <gabriel@telnyx.com> (http://www.telnyx.com/)",
18
- "Lucas Rosa <lucas@telnyx.com> (http://www.telnyx.com/)",
19
- "Rômulo Garofalo <romulo@telnyx.com> (http://www.telnyx.com/)",
16
+ "Vlad Ionash <vladi@telnyx.com> (http://telnyx.com)",
17
+ "Gabriel Taylor Russ <gabriel@telnyx.com> (http://telnyx.com)",
18
+ "Lucas Rosa <lucas@telnyx.com> (http://telnyx.com)",
19
+ "Rômulo Garofalo <romulo@telnyx.com> (http://telnyx.com)",
20
20
  "Khalil Mohammad <khalilmohammadmirza@gmail.com> (https://khalilmohammadmirza.com)"
21
21
  ],
22
22
  "repository": {
23
23
  "type": "git",
24
24
  "url": "git://github.com/team-telnyx/telnyx-node.git"
25
25
  },
26
- "bugs:": "https://github.com/team-telnyx/telnyx-node/issues",
26
+ "bugs": "https://github.com/team-telnyx/telnyx-node/issues",
27
27
  "engines": {
28
- "node": "^6 || >=8"
28
+ "node": "^18 || >=20"
29
29
  },
30
- "main": "lib/telnyx.js",
30
+ "main": "dist/telnyx.node.js",
31
+ "type": "module",
32
+ "types": "dist/types/index.d.ts",
31
33
  "devDependencies": {
32
- "chai": "~4.4.1",
33
- "chai-as-promised": "~7.1.1",
34
- "coveralls": "^3.1.1",
34
+ "@eslint/js": "^9.10.0",
35
+ "@stoplight/prism-cli": "^5.10.0",
36
+ "@types/eslint__js": "^8.42.3",
37
+ "@types/jest": "^29.5.13",
38
+ "@types/node": "^22.7.3",
39
+ "@types/qs": "^6.9.15",
35
40
  "debug": "^4.3.4",
36
41
  "eslint": "^8.57.0",
42
+ "eslint-config-prettier": "^9.1.0",
37
43
  "eslint-plugin-chai-friendly": "^0.7.4",
38
- "mocha": "^10.3.0",
44
+ "eslint-plugin-prettier": "^5.2.1",
45
+ "jest": "^29.7.0",
39
46
  "nock": "^13.5.4",
40
- "nyc": "^15.1.0"
41
- },
42
- "dependencies": {
43
- "lodash.isplainobject": "^4.0.6",
47
+ "nyc": "^15.1.0",
48
+ "plop": "^4.0.1",
49
+ "prettier": "^3.0.0",
44
50
  "qs": "^6.11.2",
45
- "safe-buffer": "^5.2.1",
46
- "telnyx": "^1.26.2",
51
+ "ts-jest": "^29.2.5",
52
+ "ts-node": "^10.9.2",
47
53
  "tweetnacl": "^1.0.3",
54
+ "typescript": "^5.6.2",
55
+ "typescript-eslint": "^8.8.0",
48
56
  "uuid": "^9.0.1"
49
57
  },
58
+ "overrides": {
59
+ "node-plop": {
60
+ "inquirer": "9.3.5"
61
+ }
62
+ },
50
63
  "license": "MIT",
51
64
  "scripts": {
52
- "clean": "rm -rf ./.nyc_output ./node_modules/.cache ./coverage",
53
- "mocha": "nyc mocha",
54
- "test": "npm run lint && npm run mocha",
55
- "lint": "eslint . --fix",
56
- "report": "nyc -r text -r lcov report",
57
- "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
58
- "release": "telnyx-npm-release"
59
- },
60
- "nyc": {
61
- "exclude": [
62
- "testUtils/**/*",
63
- "test/**/*",
64
- "lib/TelnyxMethod.basic.js"
65
- ]
65
+ "prebuild": "rm -rf ./dist",
66
+ "build": "tsc && cp -r types dist/types",
67
+ "clean": "rm -rf ./.nyc_output ./node_modules/.cache ./coverage ./dist",
68
+ "prepack": "npm install && npm run build",
69
+ "test": "jest",
70
+ "generate": "plop",
71
+ "lint": "rm -rf ./dist && eslint .",
72
+ "fix": "npm run lint --fix"
66
73
  }
67
74
  }