telnyx 2.0.1-beta.0 → 2.1.0-beta.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 (152) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +7 -0
  3. package/VERSION +1 -1
  4. package/dist/Error.js +34 -16
  5. package/dist/TelnyxMethod.basic.js +12 -6
  6. package/dist/TelnyxMethod.js +34 -6
  7. package/dist/TelnyxResource.js +37 -9
  8. package/dist/Webhooks.js +32 -4
  9. package/dist/autoPagination.js +33 -4
  10. package/dist/makeRequest.js +27 -2
  11. package/dist/multipart.js +7 -4
  12. package/dist/resources/AccessIpAddress.js +8 -2
  13. package/dist/resources/AccessIpRanges.js +8 -2
  14. package/dist/resources/Actions.js +10 -4
  15. package/dist/resources/ActionsSimCards.js +9 -3
  16. package/dist/resources/ActivateDeactivateBulkCredentials.js +33 -4
  17. package/dist/resources/Addresses.js +33 -4
  18. package/dist/resources/AiAssistants.js +9 -3
  19. package/dist/resources/AiAudioTranscriptions.js +8 -2
  20. package/dist/resources/AiChatCompletions.js +8 -2
  21. package/dist/resources/AiEmbeddings.js +9 -3
  22. package/dist/resources/AiEmbeddingsBuckets.js +9 -3
  23. package/dist/resources/AiEmbeddingsSimilaritySearch.js +8 -2
  24. package/dist/resources/AiModels.js +8 -2
  25. package/dist/resources/AiSummarize.js +8 -2
  26. package/dist/resources/AuditEvents.js +8 -2
  27. package/dist/resources/AuthenticationProviders.js +8 -2
  28. package/dist/resources/AvailablePhoneNumbers.js +8 -2
  29. package/dist/resources/AvailablePhoneNumbersBlocks.js +8 -2
  30. package/dist/resources/Balance.js +9 -3
  31. package/dist/resources/BillingGroups.js +8 -2
  32. package/dist/resources/Brands.js +9 -3
  33. package/dist/resources/BulkCredentials.js +9 -3
  34. package/dist/resources/BulkSoleProprietorCreation.js +9 -3
  35. package/dist/resources/BulkTelephonyCredentials.js +33 -4
  36. package/dist/resources/CallControlApplications.js +33 -4
  37. package/dist/resources/CallEvents.js +8 -2
  38. package/dist/resources/CallRecordings.js +9 -3
  39. package/dist/resources/Calls.js +33 -4
  40. package/dist/resources/Campaign.js +33 -4
  41. package/dist/resources/CampaignBuilder.js +33 -4
  42. package/dist/resources/CdrUsageReports.js +9 -3
  43. package/dist/resources/Channelzones.js +9 -3
  44. package/dist/resources/Conferences.js +33 -4
  45. package/dist/resources/Connections.js +9 -3
  46. package/dist/resources/CredentialConnections.js +8 -2
  47. package/dist/resources/CustomerServiceRecords.js +9 -3
  48. package/dist/resources/DetailRecords.js +9 -3
  49. package/dist/resources/DialogflowConnections.js +9 -3
  50. package/dist/resources/DocumentLinks.js +8 -2
  51. package/dist/resources/Documents.js +9 -3
  52. package/dist/resources/DynamicEmergency.js +12 -6
  53. package/dist/resources/DynamicEmergencyAddresses.js +8 -2
  54. package/dist/resources/DynamicEmergencyEndpoints.js +8 -2
  55. package/dist/resources/ExternalConnections.js +9 -3
  56. package/dist/resources/FaxApplications.js +33 -4
  57. package/dist/resources/Faxes.js +33 -4
  58. package/dist/resources/FqdnConnections.js +33 -4
  59. package/dist/resources/Fqdns.js +33 -4
  60. package/dist/resources/GlobalIps.js +9 -3
  61. package/dist/resources/InboundChannels.js +9 -3
  62. package/dist/resources/InventoryCoverage.js +9 -3
  63. package/dist/resources/IpConnections.js +33 -4
  64. package/dist/resources/Ips.js +33 -4
  65. package/dist/resources/ManagedAccounts.js +33 -4
  66. package/dist/resources/MdrDetailReports.js +9 -3
  67. package/dist/resources/MdrUsageReports.js +9 -3
  68. package/dist/resources/MediaStorageApi.js +9 -3
  69. package/dist/resources/Messages.js +9 -3
  70. package/dist/resources/MessagingHostedNumberOrders.js +8 -2
  71. package/dist/resources/MessagingHostedNumbers.js +8 -2
  72. package/dist/resources/MessagingProfiles.js +33 -4
  73. package/dist/resources/MessagingShortCodes.js +8 -2
  74. package/dist/resources/MessagingTollfreeVerification.js +9 -3
  75. package/dist/resources/MessagingUrlDomains.js +9 -3
  76. package/dist/resources/MobileNetworkOperators.js +9 -3
  77. package/dist/resources/MobileOperatorNetworks.js +8 -2
  78. package/dist/resources/Networks.js +9 -3
  79. package/dist/resources/NotificationEvents.js +8 -2
  80. package/dist/resources/NumberBackgroundJobs.js +9 -3
  81. package/dist/resources/NumberLookup.js +8 -2
  82. package/dist/resources/NumberOrders.js +33 -4
  83. package/dist/resources/NumberPortouts.js +33 -4
  84. package/dist/resources/NumberReservations.js +33 -4
  85. package/dist/resources/NumbersFeatures.js +9 -3
  86. package/dist/resources/Object.js +9 -3
  87. package/dist/resources/OtaUpdates.js +9 -3
  88. package/dist/resources/OutboundVoiceProfiles.js +33 -4
  89. package/dist/resources/Payment.js +9 -3
  90. package/dist/resources/PhoneNumberAssignmentByProfile.js +33 -4
  91. package/dist/resources/PhoneNumberBlockOrders.js +9 -3
  92. package/dist/resources/PhoneNumberBlocksBackgroundJobs.js +9 -3
  93. package/dist/resources/PhoneNumberCampaigns.js +9 -3
  94. package/dist/resources/PhoneNumbers.js +37 -8
  95. package/dist/resources/PhoneNumbersCsvDownloads.js +8 -2
  96. package/dist/resources/PhoneNumbersMessaging.js +8 -2
  97. package/dist/resources/PhoneNumbersRegulatoryRequirements.js +8 -2
  98. package/dist/resources/PhoneNumbersSlim.js +8 -2
  99. package/dist/resources/PhoneNumbersVoice.js +8 -2
  100. package/dist/resources/PortabilityChecks.js +9 -3
  101. package/dist/resources/PortingEvents.js +9 -3
  102. package/dist/resources/PortingLoaConfigurations.js +9 -3
  103. package/dist/resources/PortingOrders.js +33 -4
  104. package/dist/resources/PortingPhoneNumbers.js +8 -2
  105. package/dist/resources/PortingReports.js +8 -2
  106. package/dist/resources/PortoutEvents.js +9 -3
  107. package/dist/resources/PortoutRequests.js +9 -3
  108. package/dist/resources/PresignedObjectUrls.js +9 -3
  109. package/dist/resources/PrivateWirelessGateways.js +9 -3
  110. package/dist/resources/PublicInternetGateways.js +9 -3
  111. package/dist/resources/PushCredentials.js +9 -3
  112. package/dist/resources/Queues.js +33 -4
  113. package/dist/resources/RecordingsCommands.js +9 -3
  114. package/dist/resources/Regions.js +9 -3
  115. package/dist/resources/RegulatoryRequirements.js +8 -2
  116. package/dist/resources/Reporting.js +9 -3
  117. package/dist/resources/Reports.js +9 -3
  118. package/dist/resources/ReportsMdrs.js +8 -2
  119. package/dist/resources/RequirementTypes.js +9 -3
  120. package/dist/resources/Requirements.js +9 -3
  121. package/dist/resources/RoomCompositions.js +8 -2
  122. package/dist/resources/RoomParticipants.js +8 -2
  123. package/dist/resources/RoomRecordings.js +9 -3
  124. package/dist/resources/RoomSessions.js +9 -3
  125. package/dist/resources/Rooms.js +8 -2
  126. package/dist/resources/RoomsClientToken.js +9 -3
  127. package/dist/resources/RoomsClientTokens.js +9 -3
  128. package/dist/resources/SharedCampaigns.js +9 -3
  129. package/dist/resources/ShortCodes.js +33 -4
  130. package/dist/resources/SimCardActions.js +9 -3
  131. package/dist/resources/SimCardGroupActions.js +9 -3
  132. package/dist/resources/SimCardGroups.js +33 -4
  133. package/dist/resources/SimCardOrders.js +8 -2
  134. package/dist/resources/SimCards.js +33 -4
  135. package/dist/resources/StorageBuckets.js +9 -3
  136. package/dist/resources/TelephonyCredentials.js +33 -4
  137. package/dist/resources/Texml.js +9 -3
  138. package/dist/resources/TexmlApplications.js +33 -4
  139. package/dist/resources/Verifications.js +33 -4
  140. package/dist/resources/VerifiedNumbers.js +33 -4
  141. package/dist/resources/VerifyProfiles.js +9 -3
  142. package/dist/resources/VirtualCrossConnects.js +9 -3
  143. package/dist/resources/WdrDetailReports.js +9 -3
  144. package/dist/resources/Webhooks.js +8 -2
  145. package/dist/resources/WireguardInterfaces.js +9 -3
  146. package/dist/resources/WirelessDetailRecordReports.js +8 -2
  147. package/dist/telnyx.js +313 -284
  148. package/dist/telnyx.node.js +6 -3
  149. package/dist/types/DocumentsResource.d.ts +1 -1
  150. package/dist/types/TelnyxAPI.d.ts +6826 -2933
  151. package/dist/utils.js +64 -20
  152. package/package.json +15 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## v2
4
4
 
5
+ ### v2.1.0
6
+
7
+ - Add dual package support for both CommonJS and ES modules
8
+ - Maintain backward compatibility with existing code
9
+
5
10
  ### v2.0.1
6
11
 
7
12
  - Add Messaging Inbound Webhook example
package/README.md CHANGED
@@ -335,6 +335,13 @@ Now inject envs into terminal:
335
335
 
336
336
  > 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
337
337
 
338
+
339
+ Update global types based off Telnyx OpenAPI spec with the following command:
340
+
341
+ ```bash
342
+ npx openapi-typescript https://raw.githubusercontent.com/team-telnyx/openapi/master/openapi/spec3.json -o ./types/TelnyxAPI.d.ts
343
+ ```
344
+
338
345
  The test suite depends on the [Prism Mock Server](https://github.com/stoplightio/prism).
339
346
 
340
347
  Start the prism mock service with the following command:
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1-beta.0
1
+ 2.1.0-beta.0
package/dist/Error.js CHANGED
@@ -1,4 +1,7 @@
1
- export const generate = (rawTelnyxError) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TelnyxSignatureVerificationError = exports.TelnyxConnectionError = exports.TelnyxServiceUnavailableError = exports.TelnyxRateLimitError = exports.TelnyxInvalidParametersError = exports.TelnyxUnsupportedMediaTypeError = exports.TelnyxTimeoutError = exports.TelnyxMethodNotSupportedError = exports.TelnyxResourceNotFoundError = exports.TelnyxPermissionError = exports.TelnyxAuthenticationError = exports.TelnyxAPIError = exports.TelnyxInvalidRequestError = exports.TelnyxError = exports.generate = void 0;
4
+ const generate = (rawTelnyxError) => {
2
5
  switch (rawTelnyxError.statusCode) {
3
6
  case 400:
4
7
  return new TelnyxInvalidRequestError(rawTelnyxError);
@@ -25,11 +28,12 @@ export const generate = (rawTelnyxError) => {
25
28
  }
26
29
  return new TelnyxError({ type: 'Generic', message: 'Unknown Error' });
27
30
  };
31
+ exports.generate = generate;
28
32
  /**
29
33
  * TelnyxError is the base error from which all other more specific Telnyx errors derive.
30
34
  * Specifically for errors returned from Telnyx's REST API.
31
35
  */
32
- export class TelnyxError extends Error {
36
+ class TelnyxError extends Error {
33
37
  message;
34
38
  type;
35
39
  raw;
@@ -55,102 +59,116 @@ export class TelnyxError extends Error {
55
59
  /**
56
60
  * Helper factory which takes raw Telnyx errors and outputs wrapping instances
57
61
  */
58
- static generate = generate;
62
+ static generate = exports.generate;
59
63
  }
64
+ exports.TelnyxError = TelnyxError;
60
65
  /**
61
66
  * InvalidRequestError is raised when a request is initiated with invalid
62
67
  * parameters.
63
68
  */
64
- export class TelnyxInvalidRequestError extends TelnyxError {
69
+ class TelnyxInvalidRequestError extends TelnyxError {
65
70
  constructor(raw = {}) {
66
71
  super(raw, 'TelnyxInvalidRequestError');
67
72
  }
68
73
  }
74
+ exports.TelnyxInvalidRequestError = TelnyxInvalidRequestError;
69
75
  /**
70
76
  * APIError is a generic error that may be raised in cases where none of the
71
77
  * other named errors cover the problem. It could also be raised in the case
72
78
  * that a new error has been introduced in the API, but this version of the
73
79
  * Node.JS SDK doesn't know how to handle it.
74
80
  */
75
- export class TelnyxAPIError extends TelnyxError {
81
+ class TelnyxAPIError extends TelnyxError {
76
82
  constructor(raw = {}) {
77
83
  super(raw, 'TelnyxAPIError');
78
84
  }
79
85
  }
86
+ exports.TelnyxAPIError = TelnyxAPIError;
80
87
  /**
81
88
  * AuthenticationError is raised when invalid credentials are used to connect
82
89
  * to Telnyx's servers.
83
90
  */
84
- export class TelnyxAuthenticationError extends TelnyxError {
91
+ class TelnyxAuthenticationError extends TelnyxError {
85
92
  constructor(raw = {}) {
86
93
  super(raw, 'TelnyxAuthenticationError');
87
94
  }
88
95
  }
96
+ exports.TelnyxAuthenticationError = TelnyxAuthenticationError;
89
97
  /**
90
98
  * PermissionError is raised in cases where access was attempted on a resource
91
99
  * that wasn't allowed.
92
100
  */
93
- export class TelnyxPermissionError extends TelnyxError {
101
+ class TelnyxPermissionError extends TelnyxError {
94
102
  constructor(raw = {}) {
95
103
  super(raw, 'TelnyxPermissionError');
96
104
  }
97
105
  }
98
- export class TelnyxResourceNotFoundError extends TelnyxError {
106
+ exports.TelnyxPermissionError = TelnyxPermissionError;
107
+ class TelnyxResourceNotFoundError extends TelnyxError {
99
108
  constructor(raw = {}) {
100
109
  super(raw, 'TelnyxResourceNotFoundError');
101
110
  }
102
111
  }
103
- export class TelnyxMethodNotSupportedError extends TelnyxError {
112
+ exports.TelnyxResourceNotFoundError = TelnyxResourceNotFoundError;
113
+ class TelnyxMethodNotSupportedError extends TelnyxError {
104
114
  constructor(raw = {}) {
105
115
  super(raw, 'TelnyxMethodNotSupportedError');
106
116
  }
107
117
  }
108
- export class TelnyxTimeoutError extends TelnyxError {
118
+ exports.TelnyxMethodNotSupportedError = TelnyxMethodNotSupportedError;
119
+ class TelnyxTimeoutError extends TelnyxError {
109
120
  constructor(raw = {}) {
110
121
  super(raw, 'TelnyxTimeoutError');
111
122
  }
112
123
  }
113
- export class TelnyxUnsupportedMediaTypeError extends TelnyxError {
124
+ exports.TelnyxTimeoutError = TelnyxTimeoutError;
125
+ class TelnyxUnsupportedMediaTypeError extends TelnyxError {
114
126
  constructor(raw = {}) {
115
127
  super(raw, 'TelnyxUnsupportedMediaTypeError');
116
128
  }
117
129
  }
118
- export class TelnyxInvalidParametersError extends TelnyxError {
130
+ exports.TelnyxUnsupportedMediaTypeError = TelnyxUnsupportedMediaTypeError;
131
+ class TelnyxInvalidParametersError extends TelnyxError {
119
132
  constructor(raw = {}) {
120
133
  super(raw, 'TelnyxInvalidParametersError');
121
134
  }
122
135
  }
136
+ exports.TelnyxInvalidParametersError = TelnyxInvalidParametersError;
123
137
  /**
124
138
  * RateLimitError is raised in cases where an account is putting too much load
125
139
  * on Telnyx's API servers (usually by performing too many requests). Please
126
140
  * back off on request rate.
127
141
  */
128
- export class TelnyxRateLimitError extends TelnyxError {
142
+ class TelnyxRateLimitError extends TelnyxError {
129
143
  constructor(raw = {}) {
130
144
  super(raw, 'TelnyxRateLimitError');
131
145
  }
132
146
  }
133
- export class TelnyxServiceUnavailableError extends TelnyxError {
147
+ exports.TelnyxRateLimitError = TelnyxRateLimitError;
148
+ class TelnyxServiceUnavailableError extends TelnyxError {
134
149
  constructor(raw = {}) {
135
150
  super(raw, 'TelnyxServiceUnavailableError');
136
151
  }
137
152
  }
153
+ exports.TelnyxServiceUnavailableError = TelnyxServiceUnavailableError;
138
154
  /**
139
155
  * TelnyxConnectionError is raised in the event that the SDK can't connect to
140
156
  * Telnyx's servers. That can be for a variety of different reasons from a
141
157
  * downed network to a bad TLS certificate.
142
158
  */
143
- export class TelnyxConnectionError extends TelnyxError {
159
+ class TelnyxConnectionError extends TelnyxError {
144
160
  constructor(raw = {}) {
145
161
  super(raw, 'TelnyxConnectionError');
146
162
  }
147
163
  }
164
+ exports.TelnyxConnectionError = TelnyxConnectionError;
148
165
  /**
149
166
  * SignatureVerificationError is raised when the signature verification for a
150
167
  * webhook fails
151
168
  */
152
- export class TelnyxSignatureVerificationError extends TelnyxError {
169
+ class TelnyxSignatureVerificationError extends TelnyxError {
153
170
  constructor(raw = {}) {
154
171
  super(raw, 'TelnyxSignatureVerificationError');
155
172
  }
156
173
  }
174
+ exports.TelnyxSignatureVerificationError = TelnyxSignatureVerificationError;
@@ -1,23 +1,29 @@
1
- import telnyxMethod from './TelnyxMethod.js';
2
- export const create = telnyxMethod({
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.del = exports.update = exports.retrieve = exports.list = exports.create = void 0;
7
+ const TelnyxMethod_js_1 = __importDefault(require("./TelnyxMethod.js"));
8
+ exports.create = (0, TelnyxMethod_js_1.default)({
3
9
  method: 'POST',
4
10
  });
5
- export const list = telnyxMethod({
11
+ exports.list = (0, TelnyxMethod_js_1.default)({
6
12
  method: 'GET',
7
13
  methodType: 'list',
8
14
  });
9
- export const retrieve = telnyxMethod({
15
+ exports.retrieve = (0, TelnyxMethod_js_1.default)({
10
16
  method: 'GET',
11
17
  path: '/{id}',
12
18
  urlParams: ['id'],
13
19
  });
14
- export const update = telnyxMethod({
20
+ exports.update = (0, TelnyxMethod_js_1.default)({
15
21
  method: 'PATCH',
16
22
  path: '{id}',
17
23
  urlParams: ['id'],
18
24
  });
19
25
  // Avoid 'delete' keyword in JS
20
- export const del = telnyxMethod({
26
+ exports.del = (0, TelnyxMethod_js_1.default)({
21
27
  method: 'DELETE',
22
28
  path: '{id}',
23
29
  urlParams: ['id'],
@@ -1,6 +1,34 @@
1
- import * as utils from './utils.js';
2
- import makeRequest from './makeRequest.js';
3
- import { makeAutoPaginationMethods } from './autoPagination.js';
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const utils = __importStar(require("./utils.js"));
30
+ const makeRequest_js_1 = __importDefault(require("./makeRequest.js"));
31
+ const autoPagination_js_1 = require("./autoPagination.js");
4
32
  /**
5
33
  * Create an API method from the declared spec.
6
34
  *
@@ -29,9 +57,9 @@ function telnyxMethod(spec) {
29
57
  populateUrlParamsWithResource(this, args, spec);
30
58
  }
31
59
  const callback = typeof args[args.length - 1] == 'function' && args.pop();
32
- const requestPromise = utils.callbackifyPromiseWithTimeout(makeRequest(this, args, spec, {}), callback);
60
+ const requestPromise = utils.callbackifyPromiseWithTimeout((0, makeRequest_js_1.default)(this, args, spec, {}), callback);
33
61
  if (spec.methodType === 'list') {
34
- const autoPaginationMethods = makeAutoPaginationMethods(this, args, spec, requestPromise);
62
+ const autoPaginationMethods = (0, autoPagination_js_1.makeAutoPaginationMethods)(this, args, spec, requestPromise);
35
63
  Object.assign(requestPromise, autoPaginationMethods);
36
64
  }
37
65
  return requestPromise;
@@ -58,4 +86,4 @@ function populateUrlParamsWithResource(self, args, spec) {
58
86
  args.unshift(spec.paramsValues);
59
87
  }
60
88
  }
61
- export default telnyxMethod;
89
+ exports.default = telnyxMethod;
@@ -1,15 +1,43 @@
1
- import * as http from 'http';
2
- import * as https from 'https';
3
- import * as path from 'path';
4
- import * as utils from './utils.js';
5
- import * as TelnyxError from './Error.js';
6
- import TelnyxMethod from './TelnyxMethod.js';
7
- import * as basicMethods from './TelnyxMethod.basic.js';
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const http = __importStar(require("http"));
30
+ const https = __importStar(require("https"));
31
+ const path = __importStar(require("path"));
32
+ const utils = __importStar(require("./utils.js"));
33
+ const TelnyxError = __importStar(require("./Error.js"));
34
+ const TelnyxMethod_js_1 = __importDefault(require("./TelnyxMethod.js"));
35
+ const basicMethods = __importStar(require("./TelnyxMethod.basic.js"));
8
36
  const hasOwn = {}.hasOwnProperty;
9
37
  // Provide extension mechanism for Telnyx Resource Sub-Classes
10
38
  TelnyxResource.extend = utils.protoExtend;
11
39
  // Expose method-creator & prepared (basic) methods
12
- TelnyxResource.method = TelnyxMethod;
40
+ TelnyxResource.method = TelnyxMethod_js_1.default;
13
41
  TelnyxResource.BASIC_METHODS = basicMethods;
14
42
  TelnyxResource.MAX_BUFFERED_REQUEST_METRICS = 100;
15
43
  /**
@@ -394,4 +422,4 @@ TelnyxResource.prototype = {
394
422
  }
395
423
  },
396
424
  };
397
- export default TelnyxResource;
425
+ exports.default = TelnyxResource;
package/dist/Webhooks.js CHANGED
@@ -1,5 +1,33 @@
1
- import nacl from 'tweetnacl';
2
- import * as TelnyxError from './Error.js';
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const tweetnacl_1 = __importDefault(require("tweetnacl"));
30
+ const TelnyxError = __importStar(require("./Error.js"));
3
31
  const Webhooks = {
4
32
  DEFAULT_TOLERANCE: 300, // 5 minutes
5
33
  decoder: new TextDecoder('utf8'),
@@ -15,7 +43,7 @@ const Webhooks = {
15
43
  let verification;
16
44
  try {
17
45
  // https://bun.sh/guides/binary/buffer-to-typedarray
18
- verification = nacl.sign.detached.verify(payloadBuffer, signature, publicKey);
46
+ verification = tweetnacl_1.default.sign.detached.verify(payloadBuffer, signature, publicKey);
19
47
  }
20
48
  catch (_e) {
21
49
  console.log(_e);
@@ -49,4 +77,4 @@ function throwSignatureVerificationError(payload, signatureHeader, timestampHead
49
77
  },
50
78
  });
51
79
  }
52
- export default Webhooks;
80
+ exports.default = Webhooks;
@@ -1,6 +1,35 @@
1
- import makeRequest from './makeRequest.js';
2
- import * as utils from './utils.js';
3
- export function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) {
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.makeAutoPaginationMethods = makeAutoPaginationMethods;
30
+ const makeRequest_js_1 = __importDefault(require("./makeRequest.js"));
31
+ const utils = __importStar(require("./utils.js"));
32
+ function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) {
4
33
  const promiseCache = { currentPromise: null };
5
34
  let listPromise = firstPagePromise;
6
35
  let i = 0;
@@ -20,7 +49,7 @@ export function makeAutoPaginationMethods(self, requestArgs, spec, firstPageProm
20
49
  i = 0;
21
50
  const nextPageNumber = getNextPageNumber(listResult);
22
51
  const pageSize = getPageSize(listResult);
23
- listPromise = makeRequest(self, requestArgs, spec, {
52
+ listPromise = (0, makeRequest_js_1.default)(self, requestArgs, spec, {
24
53
  page: { number: nextPageNumber, size: pageSize },
25
54
  });
26
55
  return listPromise.then(iterate);
@@ -1,4 +1,29 @@
1
- import * as utils from './utils.js';
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const utils = __importStar(require("./utils.js"));
2
27
  const OPTIONAL_REGEX = /^optional!/;
3
28
  function _getRequestOpts(self, requestArgs, spec, overrideData) {
4
29
  // Extract spec values with defaults.
@@ -105,4 +130,4 @@ function makeRequest(self, requestArgs, spec, overrideData) {
105
130
  self._request(opts.requestMethod, opts.host, opts.requestPath, opts.data, opts.auth, { headers: opts.headers }, requestCallback);
106
131
  });
107
132
  }
108
- export default makeRequest;
133
+ exports.default = makeRequest;
package/dist/multipart.js CHANGED
@@ -1,4 +1,7 @@
1
- import { flattenAndStringify, stringifyRequestData } from './utils.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.multipartRequestDataProcessor = multipartRequestDataProcessor;
4
+ const utils_js_1 = require("./utils.js");
2
5
  // Method for formatting HTTP body for the multipart/form-data specification
3
6
  // Mostly taken from Fermata.js
4
7
  // https://github.com/natevw/fermata/blob/5d9732a33d776ce925013a265935facd1626cc88/fermata.js#L315-L343
@@ -19,7 +22,7 @@ function multipartDataGenerator(_method, data, headers = {}) {
19
22
  function q(s) {
20
23
  return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`;
21
24
  }
22
- const flattenedData = flattenAndStringify(data);
25
+ const flattenedData = (0, utils_js_1.flattenAndStringify)(data);
23
26
  for (const k in flattenedData) {
24
27
  if (!Object.prototype.hasOwnProperty.call(flattenedData, k)) {
25
28
  continue;
@@ -45,10 +48,10 @@ function multipartDataGenerator(_method, data, headers = {}) {
45
48
  push('--' + segno + '--');
46
49
  return buffer;
47
50
  }
48
- export function multipartRequestDataProcessor(method, data, headers, callback) {
51
+ function multipartRequestDataProcessor(method, data, headers, callback) {
49
52
  data = data || {};
50
53
  if (method !== 'POST') {
51
- return callback(null, stringifyRequestData(data));
54
+ return callback(null, (0, utils_js_1.stringifyRequestData)(data));
52
55
  }
53
56
  this._telnyx._platformFunctions
54
57
  .tryBufferData(data)
@@ -1,5 +1,11 @@
1
- import TelnyxResource from '../TelnyxResource.js';
2
- export const AccessIpAddress = TelnyxResource.extend({
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AccessIpAddress = void 0;
7
+ const TelnyxResource_js_1 = __importDefault(require("../TelnyxResource.js"));
8
+ exports.AccessIpAddress = TelnyxResource_js_1.default.extend({
3
9
  path: 'access_ip_address',
4
10
  includeBasic: ['list', 'create', 'retrieve', 'del'],
5
11
  });
@@ -1,5 +1,11 @@
1
- import TelnyxResource from '../TelnyxResource.js';
2
- export const AccessIpRanges = TelnyxResource.extend({
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AccessIpRanges = void 0;
7
+ const TelnyxResource_js_1 = __importDefault(require("../TelnyxResource.js"));
8
+ exports.AccessIpRanges = TelnyxResource_js_1.default.extend({
3
9
  path: 'access_ip_ranges',
4
10
  includeBasic: ['list', 'create', 'retrieve', 'del'],
5
11
  });
@@ -1,8 +1,14 @@
1
- import TelnyxResource from '../TelnyxResource.js';
2
- import { ActionsSimCards } from './ActionsSimCards.js';
3
- export const Actions = TelnyxResource.extend({
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Actions = void 0;
7
+ const TelnyxResource_js_1 = __importDefault(require("../TelnyxResource.js"));
8
+ const ActionsSimCards_js_1 = require("./ActionsSimCards.js");
9
+ exports.Actions = TelnyxResource_js_1.default.extend({
4
10
  path: 'actions',
5
11
  nestedResources: {
6
- SimCards: ActionsSimCards,
12
+ SimCards: ActionsSimCards_js_1.ActionsSimCards,
7
13
  },
8
14
  });
@@ -1,6 +1,12 @@
1
- import TelnyxResource from '../TelnyxResource.js';
2
- const telnyxMethod = TelnyxResource.method;
3
- export const ActionsSimCards = TelnyxResource.extend({
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ActionsSimCards = void 0;
7
+ const TelnyxResource_js_1 = __importDefault(require("../TelnyxResource.js"));
8
+ const telnyxMethod = TelnyxResource_js_1.default.method;
9
+ exports.ActionsSimCards = TelnyxResource_js_1.default.extend({
4
10
  path: 'actions',
5
11
  register: telnyxMethod({
6
12
  method: 'POST',
@@ -1,10 +1,39 @@
1
- import TelnyxResource from '../TelnyxResource.js';
2
- import * as utils from '../utils.js';
3
- const telnyxMethod = TelnyxResource.method;
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ActivateDeactivateBulkCredentials = void 0;
30
+ const TelnyxResource_js_1 = __importDefault(require("../TelnyxResource.js"));
31
+ const utils = __importStar(require("../utils.js"));
32
+ const telnyxMethod = TelnyxResource_js_1.default.method;
4
33
  function transformResponseData(response, telnyx) {
5
34
  return utils.addResourceToResponseData(response, telnyx, 'actions', {});
6
35
  }
7
- export const ActivateDeactivateBulkCredentials = TelnyxResource.extend({
36
+ exports.ActivateDeactivateBulkCredentials = TelnyxResource_js_1.default.extend({
8
37
  path: 'actions',
9
38
  create: telnyxMethod({
10
39
  method: 'POST',