teleleo 0.0.0-stage → 0.1.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 (140) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +185 -2
  4. package/api.md +183 -0
  5. package/dist/client.d.ts +28 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +27 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/core.d.ts +62 -0
  10. package/dist/core.d.ts.map +1 -0
  11. package/dist/core.js +195 -0
  12. package/dist/core.js.map +1 -0
  13. package/dist/errors.d.ts +84 -0
  14. package/dist/errors.d.ts.map +1 -0
  15. package/dist/errors.js +155 -0
  16. package/dist/errors.js.map +1 -0
  17. package/dist/index.d.ts +23 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +23 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/pagination.d.ts +41 -0
  22. package/dist/pagination.d.ts.map +1 -0
  23. package/dist/pagination.js +98 -0
  24. package/dist/pagination.js.map +1 -0
  25. package/dist/resource.d.ts +7 -0
  26. package/dist/resource.d.ts.map +1 -0
  27. package/dist/resource.js +8 -0
  28. package/dist/resource.js.map +1 -0
  29. package/dist/resources/call-scenarios.d.ts +65 -0
  30. package/dist/resources/call-scenarios.d.ts.map +1 -0
  31. package/dist/resources/call-scenarios.js +125 -0
  32. package/dist/resources/call-scenarios.js.map +1 -0
  33. package/dist/resources/calls.d.ts +49 -0
  34. package/dist/resources/calls.d.ts.map +1 -0
  35. package/dist/resources/calls.js +85 -0
  36. package/dist/resources/calls.js.map +1 -0
  37. package/dist/resources/contact-groups.d.ts +55 -0
  38. package/dist/resources/contact-groups.d.ts.map +1 -0
  39. package/dist/resources/contact-groups.js +89 -0
  40. package/dist/resources/contact-groups.js.map +1 -0
  41. package/dist/resources/contacts.d.ts +63 -0
  42. package/dist/resources/contacts.d.ts.map +1 -0
  43. package/dist/resources/contacts.js +120 -0
  44. package/dist/resources/contacts.js.map +1 -0
  45. package/dist/resources/dongles.d.ts +157 -0
  46. package/dist/resources/dongles.d.ts.map +1 -0
  47. package/dist/resources/dongles.js +248 -0
  48. package/dist/resources/dongles.js.map +1 -0
  49. package/dist/resources/files.d.ts +44 -0
  50. package/dist/resources/files.d.ts.map +1 -0
  51. package/dist/resources/files.js +65 -0
  52. package/dist/resources/files.js.map +1 -0
  53. package/dist/resources/follow-up-sms-settings.d.ts +55 -0
  54. package/dist/resources/follow-up-sms-settings.d.ts.map +1 -0
  55. package/dist/resources/follow-up-sms-settings.js +101 -0
  56. package/dist/resources/follow-up-sms-settings.js.map +1 -0
  57. package/dist/resources/index.d.ts +50 -0
  58. package/dist/resources/index.d.ts.map +1 -0
  59. package/dist/resources/index.js +36 -0
  60. package/dist/resources/index.js.map +1 -0
  61. package/dist/resources/mailings.d.ts +71 -0
  62. package/dist/resources/mailings.d.ts.map +1 -0
  63. package/dist/resources/mailings.js +177 -0
  64. package/dist/resources/mailings.js.map +1 -0
  65. package/dist/resources/public-vpn.d.ts +43 -0
  66. package/dist/resources/public-vpn.d.ts.map +1 -0
  67. package/dist/resources/public-vpn.js +59 -0
  68. package/dist/resources/public-vpn.js.map +1 -0
  69. package/dist/resources/redirections.d.ts +55 -0
  70. package/dist/resources/redirections.d.ts.map +1 -0
  71. package/dist/resources/redirections.js +103 -0
  72. package/dist/resources/redirections.js.map +1 -0
  73. package/dist/resources/sip-users.d.ts +26 -0
  74. package/dist/resources/sip-users.d.ts.map +1 -0
  75. package/dist/resources/sip-users.js +36 -0
  76. package/dist/resources/sip-users.js.map +1 -0
  77. package/dist/resources/sms.d.ts +98 -0
  78. package/dist/resources/sms.d.ts.map +1 -0
  79. package/dist/resources/sms.js +185 -0
  80. package/dist/resources/sms.js.map +1 -0
  81. package/dist/resources/socks-proxies.d.ts +55 -0
  82. package/dist/resources/socks-proxies.d.ts.map +1 -0
  83. package/dist/resources/socks-proxies.js +81 -0
  84. package/dist/resources/socks-proxies.js.map +1 -0
  85. package/dist/resources/ussd.d.ts +61 -0
  86. package/dist/resources/ussd.d.ts.map +1 -0
  87. package/dist/resources/ussd.js +79 -0
  88. package/dist/resources/ussd.js.map +1 -0
  89. package/dist/types/enums.d.ts +259 -0
  90. package/dist/types/enums.d.ts.map +1 -0
  91. package/dist/types/enums.js +216 -0
  92. package/dist/types/enums.js.map +1 -0
  93. package/dist/types/index.d.ts +4 -0
  94. package/dist/types/index.d.ts.map +1 -0
  95. package/dist/types/index.js +5 -0
  96. package/dist/types/index.js.map +1 -0
  97. package/dist/types/models.d.ts +599 -0
  98. package/dist/types/models.d.ts.map +1 -0
  99. package/dist/types/models.js +3 -0
  100. package/dist/types/models.js.map +1 -0
  101. package/dist/types/params.d.ts +711 -0
  102. package/dist/types/params.d.ts.map +1 -0
  103. package/dist/types/params.js +3 -0
  104. package/dist/types/params.js.map +1 -0
  105. package/dist/utils.d.ts +32 -0
  106. package/dist/utils.d.ts.map +1 -0
  107. package/dist/utils.js +118 -0
  108. package/dist/utils.js.map +1 -0
  109. package/dist/version.d.ts +2 -0
  110. package/dist/version.d.ts.map +1 -0
  111. package/dist/version.js +2 -0
  112. package/dist/version.js.map +1 -0
  113. package/package.json +63 -4
  114. package/src/client.ts +42 -0
  115. package/src/core.ts +274 -0
  116. package/src/errors.ts +162 -0
  117. package/src/index.ts +46 -0
  118. package/src/pagination.ts +110 -0
  119. package/src/resource.ts +10 -0
  120. package/src/resources/call-scenarios.ts +142 -0
  121. package/src/resources/calls.ts +92 -0
  122. package/src/resources/contact-groups.ts +105 -0
  123. package/src/resources/contacts.ts +137 -0
  124. package/src/resources/dongles.ts +296 -0
  125. package/src/resources/files.ts +71 -0
  126. package/src/resources/follow-up-sms-settings.ts +120 -0
  127. package/src/resources/index.ts +86 -0
  128. package/src/resources/mailings.ts +193 -0
  129. package/src/resources/public-vpn.ts +64 -0
  130. package/src/resources/redirections.ts +119 -0
  131. package/src/resources/sip-users.ts +40 -0
  132. package/src/resources/sms.ts +214 -0
  133. package/src/resources/socks-proxies.ts +97 -0
  134. package/src/resources/ussd.ts +87 -0
  135. package/src/types/enums.ts +278 -0
  136. package/src/types/index.ts +5 -0
  137. package/src/types/models.ts +654 -0
  138. package/src/types/params.ts +767 -0
  139. package/src/utils.ts +123 -0
  140. package/src/version.ts +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow [semver](https://semver.org/).
4
+
5
+ ## [0.1.0] - 2026-11-10
6
+
7
+ First release: a typed client for the 82 operations of Teleleo API v1.0.0, exceptions with API error codes, automatic pagination with `for await`, safe retries and timeouts.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Teleleo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,186 @@
1
- # Temporary Holding Version
1
+ # Teleleo TypeScript and JavaScript library
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Teleleo is a platform for managing SIM-card modems from the cloud: SMS, calls, USSD, mailings, redirections, Wi-Fi, VPN and SOCKS proxy. `teleleo` is the official TypeScript and JavaScript library for the [Teleleo REST API](https://github.com/teleleo-com/teleleo-openapi).
4
+
5
+ - Types for every request and answer, docs on every method
6
+ - Every error is an exception with the API error code
7
+ - Automatic pagination with `for await`
8
+ - Safe retries and timeouts
9
+ - No runtime dependencies; Node.js 20.19+
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install teleleo
15
+ ```
16
+
17
+ ## Quickstart
18
+
19
+ Take the API key in the Teleleo cabinet (Settings → API key) and put it into the `TELELEO_API_KEY` environment variable.
20
+
21
+ ```ts
22
+ import Teleleo from 'teleleo';
23
+
24
+ const client = new Teleleo(); // reads TELELEO_API_KEY
25
+
26
+ for await (const dongle of client.dongles.list()) {
27
+ console.log(dongle.dongle_id, dongle.name, dongle.number);
28
+ }
29
+
30
+ const sms = await client.sms.send(1234, {
31
+ number: '+447700900123',
32
+ message: 'Hello from Teleleo',
33
+ });
34
+ console.log(sms.sms_id, sms.sms_status_id);
35
+ ```
36
+
37
+ Methods take the path parameters first (`dongleId`, `smsId`, ...), then an object with the parameters of the request. The parameter and field names are the ones of the API, so the [API documentation](https://github.com/teleleo-com/teleleo-openapi) reads one to one.
38
+
39
+ ## Usage
40
+
41
+ ### Read incoming SMS
42
+
43
+ ```ts
44
+ import Teleleo, { SmsType, toDate } from 'teleleo';
45
+
46
+ const client = new Teleleo();
47
+ const since = new Date(Date.now() - 24 * 60 * 60 * 1000);
48
+
49
+ for await (const sms of client.sms.list({ sms_type_ids: [SmsType.INCOMING], from: since, limit: 100 })) {
50
+ console.log(toDate(sms.created_at), sms.number_caller, sms.message_decoded);
51
+ }
52
+ ```
53
+
54
+ Dates in answers are strings in UTC, `YYYY-MM-DD HH:MM:SS[.ffffff]`, as the API sends them; `toDate()` turns one into a `Date`. Date parameters take a `Date` or a string in the API format.
55
+
56
+ ### Pagination
57
+
58
+ A list method returns a `PagePromise`: `await` it for one page, or iterate it with `for await` to go through every item; the next pages are requested as needed.
59
+
60
+ ```ts
61
+ const page = await client.contacts.list({ limit: 50 });
62
+ console.log(page.totalCount, page.items.length);
63
+
64
+ for await (const contact of client.contacts.list({ limit: 50 })) {
65
+ console.log(contact.name);
66
+ }
67
+
68
+ let current = page;
69
+ while (current.hasNextPage()) {
70
+ current = await current.getNextPage();
71
+ }
72
+ ```
73
+
74
+ Without `page` and `limit` the API returns the whole list in one answer (mailings return the first 50).
75
+
76
+ ### Modem commands
77
+
78
+ ```ts
79
+ await client.dongles.reboot(1234);
80
+ const info = await client.dongles.getNetworkInfo(1234);
81
+ console.log(info.current_network_name, info.network_type, info.is_roaming);
82
+ ```
83
+
84
+ Every method and its parameters are listed in [api.md](api.md).
85
+
86
+ ### Errors
87
+
88
+ Every error is a subclass of `TeleleoError`. When the API answers with an error, the exception carries the machine-readable code in `errorMessage`, details in `errorDetails` and `requestId` for support.
89
+
90
+ ```ts
91
+ import Teleleo, { APIConnectionError, APIStatusError, BadRequestError, NotFoundError } from 'teleleo';
92
+
93
+ const client = new Teleleo();
94
+
95
+ try {
96
+ await client.contacts.get(999999);
97
+ } catch (error) {
98
+ if (error instanceof NotFoundError) {
99
+ console.log('No such contact:', error.errorMessage);
100
+ } else if (error instanceof BadRequestError) {
101
+ console.log(error.status, error.errorMessage, error.errorDetails);
102
+ } else if (error instanceof APIStatusError) {
103
+ console.log('Teleleo error', error.status, error.errorMessage, 'request_id:', error.requestId);
104
+ } else if (error instanceof APIConnectionError) {
105
+ console.log('Teleleo is unreachable');
106
+ } else {
107
+ throw error;
108
+ }
109
+ }
110
+ ```
111
+
112
+ | Status | Exception |
113
+ | --------------------------- | --------------------------------------- |
114
+ | 400 | `BadRequestError` |
115
+ | 400 with `*NOT_FOUND*`, 404 | `NotFoundError` |
116
+ | 401 | `AuthenticationError` |
117
+ | 403 | `PermissionDeniedError` |
118
+ | 409 | `ConflictError` |
119
+ | 429 | `RateLimitError` |
120
+ | 5xx | `InternalServerError` |
121
+ | no answer | `APIConnectionError`, `APITimeoutError` |
122
+
123
+ API v1 answers 400, not 404, for a missing object; the library throws `NotFoundError` for both, so your code keeps working when the API moves to 404.
124
+
125
+ ### Retries, timeouts and abort
126
+
127
+ Requests that failed for a transient reason are repeated twice with exponential backoff: connection errors, 429, and 408/502/503/504 for requests that are safe to repeat. A POST (sending an SMS, creating a call) is repeated only when the server could not have acted on it, so a retry never sends an SMS twice.
128
+
129
+ ```ts
130
+ const client = new Teleleo({ timeout: 20_000, maxRetries: 3 });
131
+
132
+ await client.dongles.list({}, { timeout: 5_000, maxRetries: 0 });
133
+
134
+ const controller = new AbortController();
135
+ const request = client.dongles.get(1234, { signal: controller.signal });
136
+ controller.abort();
137
+ ```
138
+
139
+ The default timeout is 60 seconds.
140
+
141
+ ### Configuration
142
+
143
+ | Option | Environment variable | Default |
144
+ | ---------------- | -------------------- | -------------------------------------------------------------- |
145
+ | `apiKey` | `TELELEO_API_KEY` | required |
146
+ | `baseURL` | `TELELEO_BASE_URL` | `https://app.teleleo.com/react_api` |
147
+ | `timeout` | | 60 000 ms |
148
+ | `maxRetries` | | 2 |
149
+ | `defaultHeaders` | | |
150
+ | `fetch` | | the global `fetch`; pass your own for proxies or custom agents |
151
+
152
+ Every method also takes request options as its last argument: `headers`, `query`, `body`, `timeout`, `maxRetries`, `signal`. Use `query` and `body` to send a parameter the library does not have yet.
153
+
154
+ ### Answers
155
+
156
+ Answers are returned as the API sends them, without validation, so a new field or enum value in the API never breaks your code. Enums are plain numbers with named constants (`SmsType.INCOMING === 2`).
157
+
158
+ ### CommonJS
159
+
160
+ The package is an ES module. Node.js 20.19+ and 22.12+ load it with `require()` too:
161
+
162
+ ```js
163
+ const { Teleleo } = require('teleleo');
164
+ ```
165
+
166
+ ## Versioning
167
+
168
+ The library follows [semver](https://semver.org/). Changes are listed in [CHANGELOG.md](CHANGELOG.md).
169
+
170
+ ## Development
171
+
172
+ Types and resources in `src/resources` and `src/types` are generated from [`spec/openapi.yaml`](spec/openapi.yaml):
173
+
174
+ ```bash
175
+ npm install
176
+ npm run generate
177
+ npm test
178
+ ```
179
+
180
+ ## Support
181
+
182
+ support@teleleo.com · [teleleo.com](https://teleleo.com) · [issues](https://github.com/teleleo-com/teleleo-node/issues)
183
+
184
+ ## License
185
+
186
+ [MIT](LICENSE)
package/api.md ADDED
@@ -0,0 +1,183 @@
1
+ # API reference
2
+
3
+ Every method of the `Teleleo` client, generated from [`spec/openapi.yaml`](spec/openapi.yaml). Types are exported from the package root.
4
+
5
+ ## `client.dongles`
6
+
7
+ Modems of the account and their commands: reboot, Wi-Fi, Wi-Fi extender, number, network info.
8
+
9
+ | Method | HTTP | Returns | Description |
10
+ |---|---|---|---|
11
+ | `list(params?)` | `GET /dongle` | `PagePromise<DongleListItem>` | List modems |
12
+ | `reboot(dongleId)` | `POST /dongle/{dongle_id}/reboot` | `Promise<boolean>` | Reboot modem |
13
+ | `enableWifi(dongleId)` | `POST /dongle/{dongle_id}/wifi/enable` | `Promise<boolean>` | Enable modem Wi-Fi |
14
+ | `disableWifi(dongleId)` | `POST /dongle/{dongle_id}/wifi/disable` | `Promise<boolean>` | Disable modem Wi-Fi |
15
+ | `setWifiCredentials(dongleId, params)` | `POST /dongle/{dongle_id}/wifi/credentials` | `Promise<boolean>` | Set modem Wi-Fi credentials |
16
+ | `enableWifiExtender(dongleId, params)` | `POST /dongle/{dongle_id}/wifi-extender/enable` | `Promise<boolean>` | Enable Wi-Fi extender |
17
+ | `disableWifiExtender(dongleId)` | `POST /dongle/{dongle_id}/wifi-extender/disable` | `Promise<boolean>` | Disable Wi-Fi extender |
18
+ | `scanWifiNetworks(dongleId)` | `POST /dongle/{dongle_id}/wifi-extender/networks` | `Promise<boolean>` | Scan Wi-Fi networks |
19
+ | `updateOfflineNotification(dongleId, params)` | `PUT /dongle/{dongle_id}/setting/offline-notification` | `Promise<boolean>` | Set offline notification |
20
+ | `setNumber(dongleId, params)` | `PUT /dongle/{dongle_id}/number` | `Promise<boolean>` | Set modem number |
21
+ | `get(dongleId)` | `GET /dongle/{dongle_id}` | `Promise<Dongle>` | Get modem |
22
+ | `update(dongleId, params?)` | `PUT /dongle/{dongle_id}` | `Promise<Dongle>` | Update modem |
23
+ | `getNetworkInfo(dongleId)` | `POST /dongle/{dongle_id}/mobile-network-info` | `Promise<DongleNetworkInfo>` | Get modem network info |
24
+ | `getSimIdentifiers(dongleId)` | `POST /dongle/{dongle_id}/mobile-network-ids` | `Promise<DongleSimIdentifiers>` | Get modem SIM identifiers |
25
+ | `listStatistics(dongleId, params?)` | `GET /dongle/{dongle_id}/statistic` | `Promise<Array<DongleStatistic>>` | List modem traffic statistics |
26
+
27
+ ## `client.sms`
28
+
29
+ SMS of the modems: history, sending, replies, threads.
30
+
31
+ | Method | HTTP | Returns | Description |
32
+ |---|---|---|---|
33
+ | `send(dongleId, params)` | `POST /dongle/{dongle_id}/outgoing-sms` | `Promise<Sms>` | Send SMS |
34
+ | `sendToContact(dongleId, params)` | `POST /dongle/{dongle_id}/outgoing-contact-sms` | `Promise<Sms>` | Send SMS to contact |
35
+ | `reply(dongleId, params)` | `POST /dongle/{dongle_id}/reply-sms` | `Promise<Sms>` | Reply to SMS |
36
+ | `listThreads(params?)` | `GET /sms/thread` | `PagePromise<SmsThread>` | List SMS threads |
37
+ | `list(params?)` | `GET /sms` | `PagePromise<Sms>` | List SMS |
38
+ | `listForDongle(dongleId, params?)` | `GET /dongle/{dongle_id}/sms` | `PagePromise<Sms>` | List modem SMS |
39
+ | `get(dongleId, smsId)` | `GET /dongle/{dongle_id}/sms/{sms_id}` | `Promise<Sms>` | Get SMS |
40
+ | `update(dongleId, smsId, params?)` | `PUT /dongle/{dongle_id}/sms/{sms_id}` | `Promise<Sms>` | Update SMS |
41
+ | `delete(dongleId, smsId)` | `DELETE /dongle/{dongle_id}/sms/{sms_id}` | `Promise<void>` | Delete SMS |
42
+
43
+ ## `client.calls`
44
+
45
+ Calls of the modems: history, outgoing calls.
46
+
47
+ | Method | HTTP | Returns | Description |
48
+ |---|---|---|---|
49
+ | `list(params?)` | `GET /call` | `PagePromise<Call>` | List calls |
50
+ | `create(dongleId, params?)` | `POST /dongle/{dongle_id}/call` | `Promise<Call>` | Make call |
51
+ | `get(dongleId, callId)` | `GET /dongle/{dongle_id}/call/{call_id}` | `Promise<Call>` | Get call |
52
+ | `delete(dongleId, callId)` | `DELETE /dongle/{dongle_id}/call/{call_id}` | `Promise<void>` | Delete call |
53
+
54
+ ## `client.ussd`
55
+
56
+ USSD requests through a modem.
57
+
58
+ | Method | HTTP | Returns | Description |
59
+ |---|---|---|---|
60
+ | `list(dongleId, params?)` | `GET /dongle/{dongle_id}/ussd` | `PagePromise<Ussd>` | List USSD requests |
61
+ | `send(dongleId, params)` | `POST /dongle/{dongle_id}/ussd` | `Promise<Ussd>` | Send USSD |
62
+ | `get(dongleId, ussdId)` | `GET /dongle/{dongle_id}/ussd/{ussd_id}` | `Promise<Ussd>` | Get USSD request |
63
+ | `delete(dongleId, ussdId)` | `DELETE /dongle/{dongle_id}/ussd/{ussd_id}` | `Promise<boolean>` | Delete USSD request |
64
+ | `deleteAll(dongleId)` | `DELETE /dongle/{dongle_id}/ussds` | `Promise<boolean>` | Delete USSD history |
65
+
66
+ ## `client.contacts`
67
+
68
+ Address book of the account.
69
+
70
+ | Method | HTTP | Returns | Description |
71
+ |---|---|---|---|
72
+ | `list(params?)` | `GET /contact` | `PagePromise<Contact>` | List contacts |
73
+ | `create(params)` | `POST /contact` | `Promise<Contact>` | Create contact |
74
+ | `get(contactId)` | `GET /contact/{contact_id}` | `Promise<Contact>` | Get contact |
75
+ | `update(contactId, params)` | `PUT /contact/{contact_id}` | `Promise<Contact>` | Update contact |
76
+ | `delete(contactId)` | `DELETE /contact/{contact_id}` | `Promise<boolean>` | Delete contact |
77
+ | `importContacts(params)` | `POST /contact/import` | `Promise<ContactImportResult>` | Import contacts |
78
+
79
+ ## `client.contactGroups`
80
+
81
+ Groups of contacts, used by mailings, call scenarios and redirections.
82
+
83
+ | Method | HTTP | Returns | Description |
84
+ |---|---|---|---|
85
+ | `list(params?)` | `GET /contact-group` | `PagePromise<ContactGroup>` | List contact groups |
86
+ | `create(params)` | `POST /contact-group` | `Promise<ContactGroup>` | Create contact group |
87
+ | `get(contactGroupId)` | `GET /contact-group/{contact_group_id}` | `Promise<ContactGroup>` | Get contact group |
88
+ | `update(contactGroupId, params)` | `PUT /contact-group/{contact_group_id}` | `Promise<ContactGroup>` | Update contact group |
89
+ | `delete(contactGroupId)` | `DELETE /contact-group/{contact_group_id}` | `Promise<boolean>` | Delete contact group |
90
+
91
+ ## `client.mailings`
92
+
93
+ Bulk SMS and call campaigns.
94
+
95
+ | Method | HTTP | Returns | Description |
96
+ |---|---|---|---|
97
+ | `list(params?)` | `GET /mailing` | `PagePromise<Mailing>` | List mailings |
98
+ | `create(params)` | `POST /mailing` | `Promise<Mailing>` | Create mailing |
99
+ | `createSms(params)` | `POST /mailing/sms` | `Promise<Mailing>` | Create SMS mailing |
100
+ | `createCall(params)` | `POST /mailing/call` | `Promise<Mailing>` | Create call mailing |
101
+ | `get(mailingId)` | `GET /mailing/{mailing_id}` | `Promise<Mailing>` | Get mailing |
102
+ | `update(mailingId, params?)` | `PUT /mailing/{mailing_id}` | `Promise<Mailing>` | Update mailing |
103
+ | `delete(mailingId)` | `DELETE /mailing/{mailing_id}` | `Promise<boolean>` | Delete mailing |
104
+
105
+ ## `client.redirections`
106
+
107
+ Rules for incoming SMS and calls: forwarding, auto reply, HTTP callback.
108
+
109
+ | Method | HTTP | Returns | Description |
110
+ |---|---|---|---|
111
+ | `list(params?)` | `GET /redirection` | `PagePromise<Redirection>` | List redirections |
112
+ | `create(params)` | `POST /redirection` | `Promise<Redirection>` | Create redirection |
113
+ | `get(redirectionId)` | `GET /redirection/{redirection_id}` | `Promise<Redirection>` | Get redirection |
114
+ | `update(redirectionId, params)` | `PUT /redirection/{redirection_id}` | `Promise<Redirection>` | Update redirection |
115
+ | `delete(redirectionId)` | `DELETE /redirection/{redirection_id}` | `Promise<boolean>` | Delete redirection |
116
+
117
+ ## `client.callScenarios`
118
+
119
+ What a modem plays to incoming callers.
120
+
121
+ | Method | HTTP | Returns | Description |
122
+ |---|---|---|---|
123
+ | `list(params?)` | `GET /call-scenario` | `PagePromise<CallScenario>` | List call scenarios |
124
+ | `create(params)` | `POST /call-scenario` | `Promise<CallScenario>` | Create call scenario |
125
+ | `get(callScenarioId)` | `GET /call-scenario/{call_scenario_id}` | `Promise<CallScenario>` | Get call scenario |
126
+ | `update(callScenarioId, params?)` | `PUT /call-scenario/{call_scenario_id}` | `Promise<CallScenario>` | Update call scenario |
127
+ | `delete(callScenarioId)` | `DELETE /call-scenario/{call_scenario_id}` | `Promise<boolean>` | Delete call scenario |
128
+ | `retry(callScenarioId)` | `POST /call-scenario/{call_scenario_id}/retry` | `Promise<CallScenario>` | Retry call scenario delivery |
129
+
130
+ ## `client.followUpSmsSettings`
131
+
132
+ SMS a modem sends to a caller after a call.
133
+
134
+ | Method | HTTP | Returns | Description |
135
+ |---|---|---|---|
136
+ | `list(params?)` | `GET /follow-up-sms-setting` | `PagePromise<FollowUpSmsSetting>` | List follow-up SMS settings |
137
+ | `create(params)` | `POST /follow-up-sms-setting` | `Promise<FollowUpSmsSetting>` | Create follow-up SMS setting |
138
+ | `get(followUpSmsSettingId)` | `GET /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<FollowUpSmsSetting>` | Get follow-up SMS setting |
139
+ | `update(followUpSmsSettingId, params)` | `PUT /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<FollowUpSmsSetting>` | Update follow-up SMS setting |
140
+ | `delete(followUpSmsSettingId)` | `DELETE /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<boolean>` | Delete follow-up SMS setting |
141
+
142
+ ## `client.publicVpn`
143
+
144
+ VPN access through a modem.
145
+
146
+ | Method | HTTP | Returns | Description |
147
+ |---|---|---|---|
148
+ | `enable(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/enable` | `Promise<boolean>` | Enable public VPN |
149
+ | `disable(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/disable` | `Promise<boolean>` | Disable public VPN |
150
+ | `refreshPassword(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/refresh-password` | `Promise<boolean>` | Refresh public VPN password |
151
+ | `listSessions()` | `GET /public-vpn/connect-session-list` | `Promise<Array<PublicVpnSession>>` | List public VPN sessions |
152
+
153
+ ## `client.socksProxies`
154
+
155
+ SOCKS5 proxy through the mobile network of a modem.
156
+
157
+ | Method | HTTP | Returns | Description |
158
+ |---|---|---|---|
159
+ | `list(params?)` | `GET /dongle-socks-proxy` | `PagePromise<DongleSocksProxy>` | List SOCKS proxies |
160
+ | `create(params)` | `POST /dongle-socks-proxy` | `Promise<DongleSocksProxy>` | Create SOCKS proxy |
161
+ | `get(dongleSocksProxyId)` | `GET /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<DongleSocksProxy>` | Get SOCKS proxy |
162
+ | `update(dongleSocksProxyId, params)` | `PUT /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<DongleSocksProxy>` | Update SOCKS proxy |
163
+ | `delete(dongleSocksProxyId)` | `DELETE /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<boolean>` | Delete SOCKS proxy |
164
+
165
+ ## `client.sipUsers`
166
+
167
+ SIP accounts of the modems.
168
+
169
+ | Method | HTTP | Returns | Description |
170
+ |---|---|---|---|
171
+ | `list(params?)` | `GET /sip-user` | `Promise<Array<PbxSipUser>>` | List SIP users |
172
+ | `get(sipUserId)` | `GET /sip-user/{sip_user_id}` | `Promise<PbxSipUser>` | Get SIP user |
173
+
174
+ ## `client.files`
175
+
176
+ Downloads, temporary audio uploads and text-to-speech.
177
+
178
+ | Method | HTTP | Returns | Description |
179
+ |---|---|---|---|
180
+ | `download(fileId)` | `GET /file/{file_id}` | `Promise<Uint8Array>` | Get file |
181
+ | `downloadTmp(fileId)` | `GET /file/tmp/{file_id}` | `Promise<Uint8Array>` | Get temporary file |
182
+ | `uploadTmp(params)` | `POST /file/upload-tmp` | `Promise<TmpFile>` | Upload temporary file |
183
+ | `generateSpeech(params)` | `POST /file/generate-speech` | `Promise<TmpFile>` | Generate speech |
@@ -0,0 +1,28 @@
1
+ import { BaseClient, type ClientOptions } from './core.js';
2
+ import { type Resources } from './resources/index.js';
3
+ /**
4
+ * Client for the Teleleo API.
5
+ *
6
+ * ```ts
7
+ * import Teleleo from 'teleleo';
8
+ *
9
+ * const client = new Teleleo(); // reads TELELEO_API_KEY
10
+ * for await (const dongle of client.dongles.list()) {
11
+ * console.log(dongle.dongle_id, dongle.name);
12
+ * }
13
+ * ```
14
+ */
15
+ export interface Teleleo extends Resources {
16
+ }
17
+ export declare class Teleleo extends BaseClient {
18
+ constructor(options?: ClientOptions);
19
+ /**
20
+ * A copy of the client with some options changed.
21
+ *
22
+ * ```ts
23
+ * await client.withOptions({ timeout: 5_000, maxRetries: 0 }).dongles.list();
24
+ * ```
25
+ */
26
+ withOptions(options: ClientOptions): Teleleo;
27
+ }
28
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAQ,SAAQ,SAAS;CAAG;AAE7C,qBAAa,OAAQ,SAAQ,UAAU;gBACzB,OAAO,GAAE,aAAkB;IAKvC;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;CAW7C"}
package/dist/client.js ADDED
@@ -0,0 +1,27 @@
1
+ import { BaseClient } from './core.js';
2
+ import { createResources } from './resources/index.js';
3
+ export class Teleleo extends BaseClient {
4
+ constructor(options = {}) {
5
+ super(options);
6
+ Object.assign(this, createResources(this));
7
+ }
8
+ /**
9
+ * A copy of the client with some options changed.
10
+ *
11
+ * ```ts
12
+ * await client.withOptions({ timeout: 5_000, maxRetries: 0 }).dongles.list();
13
+ * ```
14
+ */
15
+ withOptions(options) {
16
+ return new Teleleo({
17
+ ...this._options,
18
+ apiKey: this.apiKey,
19
+ baseURL: this.baseURL,
20
+ timeout: this.timeout,
21
+ maxRetries: this.maxRetries,
22
+ ...options,
23
+ defaultHeaders: { ...this._options.defaultHeaders, ...options.defaultHeaders },
24
+ });
25
+ }
26
+ }
27
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAgBvE,MAAM,OAAO,OAAQ,SAAQ,UAAU;IACrC,YAAY,UAAyB,EAAE;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,OAAsB;QAChC,OAAO,IAAI,OAAO,CAAC;YACjB,GAAG,IAAI,CAAC,QAAQ;YAChB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,OAAO;YACV,cAAc,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE;SAC/E,CAAC,CAAC;IACL,CAAC;CACF"}
package/dist/core.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { PagePromise } from './pagination.js';
2
+ export declare const DEFAULT_BASE_URL = "https://app.teleleo.com/react_api";
3
+ export declare const DEFAULT_TIMEOUT = 60000;
4
+ export declare const DEFAULT_MAX_RETRIES = 2;
5
+ export interface ClientOptions {
6
+ /** The API key from the Teleleo cabinet (Settings - API key). Defaults to `process.env.TELELEO_API_KEY`. */
7
+ apiKey?: string | undefined;
8
+ /** Defaults to `process.env.TELELEO_BASE_URL`, then to `https://app.teleleo.com/react_api`. */
9
+ baseURL?: string | undefined;
10
+ /** Milliseconds before a request is aborted; 60 000 by default. */
11
+ timeout?: number | undefined;
12
+ /**
13
+ * How many times to repeat a request that failed for a transient reason; 2 by default. Requests that create
14
+ * something (POST) are repeated only when the server could not have acted on them.
15
+ */
16
+ maxRetries?: number | undefined;
17
+ /** Headers to send with every request. */
18
+ defaultHeaders?: Record<string, string> | undefined;
19
+ /** Your own `fetch`, for proxies, custom agents or tests. Defaults to the global `fetch`. */
20
+ fetch?: typeof fetch | undefined;
21
+ }
22
+ export interface RequestOptions {
23
+ /** Extra headers for this request. */
24
+ headers?: Record<string, string> | undefined;
25
+ /** Extra query parameters, for parameters the library does not have yet. */
26
+ query?: Record<string, unknown> | undefined;
27
+ /** Extra body fields, for fields the library does not have yet. */
28
+ body?: Record<string, unknown> | undefined;
29
+ /** Milliseconds before this request is aborted. */
30
+ timeout?: number | undefined;
31
+ /** Retries for this request. */
32
+ maxRetries?: number | undefined;
33
+ /** Abort the request. */
34
+ signal?: AbortSignal | undefined;
35
+ }
36
+ export declare class BaseClient {
37
+ #private;
38
+ readonly apiKey: string;
39
+ readonly baseURL: string;
40
+ readonly timeout: number;
41
+ readonly maxRetries: number;
42
+ protected readonly _options: ClientOptions;
43
+ constructor(options?: ClientOptions);
44
+ protected defaultHeaders(): Record<string, string>;
45
+ /** @internal Send a request and return the `data` of the answer. */
46
+ request(method: string, path: string, args?: {
47
+ query?: Record<string, unknown>;
48
+ body?: Record<string, unknown>;
49
+ options?: RequestOptions | undefined;
50
+ }): Promise<unknown>;
51
+ /** @internal Send a request and return the raw bytes of the answer. */
52
+ requestBytes(method: string, path: string, args?: {
53
+ options?: RequestOptions | undefined;
54
+ }): Promise<Uint8Array>;
55
+ /** @internal Request one page of a list. */
56
+ getPage<T>(path: string, args: {
57
+ query: Record<string, unknown>;
58
+ itemKey: string;
59
+ options?: RequestOptions | undefined;
60
+ }): PagePromise<T>;
61
+ }
62
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAQA,OAAO,EAAQ,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIpD,eAAO,MAAM,gBAAgB,sCAAsC,CAAC;AACpE,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAqBrC,MAAM,WAAW,aAAa;IAC5B,4GAA4G;IAC5G,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACpD,6FAA6F;IAC7F,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC7C,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5C,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC3C,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,yBAAyB;IACzB,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC;AAqCD,qBAAa,UAAU;;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;gBAG/B,OAAO,GAAE,aAAkB;IAmBvC,SAAS,CAAC,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA+ElD,oEAAoE;IAC9D,OAAO,CACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;KACjC,GACL,OAAO,CAAC,OAAO,CAAC;IAoBnB,uEAAuE;IACjE,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;QAAE,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;KAAO,GAClD,OAAO,CAAC,UAAU,CAAC;IAKtB,4CAA4C;IAC5C,OAAO,CAAC,CAAC,EACP,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;KAAE,GAC9F,WAAW,CAAC,CAAC,CAAC;CAqBlB"}