@fonoster/sdk 0.6.0 → 0.6.1-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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +358 -2
  3. package/dist/node/Applications.d.ts +206 -0
  4. package/dist/node/Applications.js +267 -0
  5. package/dist/node/client/AbstractClient.d.ts +22 -0
  6. package/dist/node/client/AbstractClient.js +86 -0
  7. package/dist/node/client/Client.d.ts +15 -0
  8. package/dist/node/client/Client.js +61 -0
  9. package/dist/node/client/TokenRefresherNode.d.ts +8 -0
  10. package/dist/node/client/TokenRefresherNode.js +43 -0
  11. package/dist/node/client/TokenRefresherWeb.d.ts +13 -0
  12. package/dist/node/client/TokenRefresherWeb.js +44 -0
  13. package/dist/node/client/isJwtExpired.d.ts +2 -0
  14. package/dist/node/client/isJwtExpired.js +38 -0
  15. package/dist/node/client/jsonToObject.d.ts +8 -0
  16. package/dist/node/client/jsonToObject.js +32 -0
  17. package/dist/node/client/makeRpcRequest.d.ts +11 -0
  18. package/dist/node/client/makeRpcRequest.js +45 -0
  19. package/dist/node/client/objectToJson.d.ts +3 -0
  20. package/dist/node/client/objectToJson.js +33 -0
  21. package/dist/node/client/types.d.ts +26 -0
  22. package/dist/node/client/types.js +2 -0
  23. package/dist/node/client/utils.d.ts +5 -0
  24. package/dist/node/client/utils.js +18 -0
  25. package/dist/node/generated/node/acls.ts +1054 -0
  26. package/dist/node/generated/node/acls_grpc_pb.js +200 -0
  27. package/dist/node/generated/node/acls_pb.js +2063 -0
  28. package/dist/node/generated/node/agents.ts +1388 -0
  29. package/dist/node/generated/node/agents_grpc_pb.js +202 -0
  30. package/dist/node/generated/node/agents_pb.js +2403 -0
  31. package/dist/node/generated/node/applications.ts +1411 -0
  32. package/dist/node/generated/node/applications_grpc_pb.js +201 -0
  33. package/dist/node/generated/node/applications_pb.js +2651 -0
  34. package/dist/node/generated/node/calls.ts +1123 -0
  35. package/dist/node/generated/node/calls_grpc_pb.js +169 -0
  36. package/dist/node/generated/node/calls_pb.js +1916 -0
  37. package/dist/node/generated/node/credentials.ts +1054 -0
  38. package/dist/node/generated/node/credentials_grpc_pb.js +200 -0
  39. package/dist/node/generated/node/credentials_pb.js +1928 -0
  40. package/dist/node/generated/node/domains.ts +1144 -0
  41. package/dist/node/generated/node/domains_grpc_pb.js +200 -0
  42. package/dist/node/generated/node/domains_pb.js +2170 -0
  43. package/dist/node/generated/node/google/protobuf/empty.ts +48 -0
  44. package/dist/node/generated/node/google/protobuf/struct.ts +408 -0
  45. package/dist/node/generated/node/identity.ts +4267 -0
  46. package/dist/node/generated/node/identity_grpc_pb.js +761 -0
  47. package/dist/node/generated/node/identity_pb.js +8058 -0
  48. package/dist/node/generated/node/numbers.ts +1371 -0
  49. package/dist/node/generated/node/numbers_grpc_pb.js +201 -0
  50. package/dist/node/generated/node/numbers_pb.js +2470 -0
  51. package/dist/node/generated/node/secrets.ts +985 -0
  52. package/dist/node/generated/node/secrets_grpc_pb.js +200 -0
  53. package/dist/node/generated/node/secrets_pb.js +1838 -0
  54. package/dist/node/generated/node/trunks.ts +1546 -0
  55. package/dist/node/generated/node/trunks_grpc_pb.js +202 -0
  56. package/dist/node/generated/node/trunks_pb.js +2777 -0
  57. package/dist/node/generated/web/AclsServiceClientPb.ts +258 -0
  58. package/dist/node/generated/web/AgentsServiceClientPb.ts +258 -0
  59. package/dist/node/generated/web/ApplicationsServiceClientPb.ts +258 -0
  60. package/dist/node/generated/web/CallsServiceClientPb.ts +194 -0
  61. package/dist/node/generated/web/CredentialsServiceClientPb.ts +258 -0
  62. package/dist/node/generated/web/DomainsServiceClientPb.ts +258 -0
  63. package/dist/node/generated/web/IdentityServiceClientPb.ts +990 -0
  64. package/dist/node/generated/web/NumbersServiceClientPb.ts +258 -0
  65. package/dist/node/generated/web/SecretsServiceClientPb.ts +258 -0
  66. package/dist/node/generated/web/TrunksServiceClientPb.ts +258 -0
  67. package/dist/node/generated/web/acls.ts +1054 -0
  68. package/dist/node/generated/web/acls_pb.d.ts +246 -0
  69. package/dist/node/generated/web/acls_pb.js +2063 -0
  70. package/dist/node/generated/web/agents.ts +1388 -0
  71. package/dist/node/generated/web/agents_pb.d.ts +300 -0
  72. package/dist/node/generated/web/agents_pb.js +2403 -0
  73. package/dist/node/generated/web/applications.ts +1411 -0
  74. package/dist/node/generated/web/applications_pb.d.ts +322 -0
  75. package/dist/node/generated/web/applications_pb.js +2651 -0
  76. package/dist/node/generated/web/calls.ts +1123 -0
  77. package/dist/node/generated/web/calls_pb.d.ts +262 -0
  78. package/dist/node/generated/web/calls_pb.js +1916 -0
  79. package/dist/node/generated/web/credentials.ts +1054 -0
  80. package/dist/node/generated/web/credentials_pb.d.ts +234 -0
  81. package/dist/node/generated/web/credentials_pb.js +1928 -0
  82. package/dist/node/generated/web/domains.ts +1144 -0
  83. package/dist/node/generated/web/domains_pb.d.ts +260 -0
  84. package/dist/node/generated/web/domains_pb.js +2170 -0
  85. package/dist/node/generated/web/google/protobuf/empty.ts +48 -0
  86. package/dist/node/generated/web/google/protobuf/struct.ts +408 -0
  87. package/dist/node/generated/web/identity.ts +4267 -0
  88. package/dist/node/generated/web/identity_pb.d.ts +973 -0
  89. package/dist/node/generated/web/identity_pb.js +8058 -0
  90. package/dist/node/generated/web/numbers.ts +1371 -0
  91. package/dist/node/generated/web/numbers_pb.d.ts +305 -0
  92. package/dist/node/generated/web/numbers_pb.js +2470 -0
  93. package/dist/node/generated/web/secrets.ts +985 -0
  94. package/dist/node/generated/web/secrets_pb.d.ts +222 -0
  95. package/dist/node/generated/web/secrets_pb.js +1838 -0
  96. package/dist/node/generated/web/trunks.ts +1546 -0
  97. package/dist/node/generated/web/trunks_pb.d.ts +338 -0
  98. package/dist/node/generated/web/trunks_pb.js +2777 -0
  99. package/dist/node/node.d.ts +2 -0
  100. package/dist/node/node.js +36 -0
  101. package/dist/node/tsconfig.node.tsbuildinfo +1 -0
  102. package/dist/node/utils.d.ts +22 -0
  103. package/dist/node/utils.js +55 -0
  104. package/dist/web/fonoster.min.js +1 -0
  105. package/dist/web/index.esm.js +1 -0
  106. package/package.json +23 -11
  107. package/dist/fonoster.min.js +0 -1
  108. package/dist/index.d.ts +0 -6
  109. package/dist/index.esm.js +0 -1
  110. package/dist/index.js +0 -1
  111. package/dist/printHello.d.ts +0 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Fonoster Inc
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,359 @@
1
- [<a href="https://gitpod.io/#https://github.com/fonoster/fonoster"> <img src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod" alt="Contribute with Gitpod" />
1
+ sdk
2
+ =================
3
+
4
+ [![Fonoster](https://img.shields.io/badge/fonoster-sdk-brightgreen.svg)](https://fonoster.com)
5
+ [![Version](https://img.shields.io/npm/v/@fonoster/sdk.svg)](https://npmjs.org/package/@fonoster/sdk)
6
+ [![Downloads/week](https://img.shields.io/npm/dw/@fonoster/sdk.svg)](https://npmjs.org/package/@fonoster/sdk)
7
+ [![License](https://img.shields.io/npm/l/@fonoster/sdk.svg)](https://github.com/fonoster/fonoster/blob/main/package.json)
8
+
9
+ This package provides a set of utilities for working with Fonoster services. It is a polymorphic SDK that can be used in a browser or a Node.js environment.
10
+
11
+ * [Installation](#installation)
12
+ * [Example](#example)
13
+ * [APIs](#apis)
14
+
15
+ ## Installation
16
+
17
+ ```sh-session
18
+ $ npm install --save @fonoster/sdk
19
+ ```
20
+
21
+ Or in the browser:
22
+
23
+ ```html
24
+ <script src="https://unpkg.com/@fonoster/sdk"></script>
25
+ ```
26
+
27
+ ### Importing the library
28
+
29
+ For CommonJS projects:
30
+
31
+ ```typescript
32
+ const SDK = require("@fonoster/sdk");
33
+ ```
34
+
35
+ For ES6 modules:
36
+
37
+ ```typescript
38
+ import * as SDK from "@fonoster/sdk";
39
+ ```
40
+
41
+ Directly in the browser:
42
+
43
+ ```html
44
+ <script src="https://unpkg.com/@fonoster/sdk"></script>
45
+ <script>
46
+ // You can now use the SDK
47
+ </script>
48
+ ```
49
+
50
+ ## Example
51
+
52
+ Create a new SDK instance to interact with the Fonoster API. The SDK requires a client object to handle communication with the API.
53
+
54
+ ### Creating a client object
55
+
56
+ In Node.js:
57
+
58
+ ```typescript
59
+ const SDK = require("@fonoster/sdk");
60
+ const accessKeyId = "WO00000000000000000000000000000000";
61
+ const client = new SDK.Client({ accessKeyId });
62
+ ```
63
+
64
+ In the browser:
65
+
66
+ ```typescript
67
+ const SDK = require("@fonoster/sdk");
68
+ const accessKeyId = "WO00000000000000000000000000000000";
69
+ const client = new SDK.WebClient({ accessKeyId });
70
+ ```
71
+
72
+ ### Initializing the client
73
+
74
+ ```typescript
75
+ const username = "admin@fonoster.local";
76
+ const password = "changeme";
77
+
78
+ client.login(username, password)
79
+ .then(console.log)
80
+ .catch(console.error);
81
+ ```
82
+
83
+ ### Making a request
84
+
85
+ ```typescript
86
+ // Requires an initialized client object
87
+ const applications = new SDK.Applications(client);
88
+
89
+ const request = {
90
+ name: "MyApp",
91
+ type: "PROGRAMMABLE_VOICE",
92
+ appEndpoint: "localhost:3000" // Your app endpoint
93
+ };
94
+
95
+ applications.createApplication(request)
96
+ .then(console.log)
97
+ .catch(console.error);
98
+ ```
99
+
100
+ ## APIs
101
+
102
+ * [`Applications`](#Applications)
103
+
104
+
105
+
106
+ <a name="Applications"></a>
107
+
108
+ ## Applications
109
+ Fonoster Applications, part of the Fonoster Voice Subsystem,
110
+ allow you to create, update, retrieve, and delete Voice Applications.
111
+ Note that an active Fonoster deployment is required.
112
+
113
+ **Kind**: global class
114
+ **See**
115
+
116
+ - AbstractClient
117
+ - FonosterClient
118
+
119
+
120
+ * [Applications](#Applications)
121
+ * [new Applications(client)](#new_Applications_new)
122
+ * [.createApplication(request)](#Applications+createApplication) ⇒ <code>Promise.&lt;CreateAppResponse&gt;</code>
123
+ * [.getApplication(request)](#Applications+getApplication) ⇒ <code>Promise.&lt;Application&gt;</code>
124
+ * [.updateApplication(request)](#Applications+updateApplication) ⇒ <code>Promise.&lt;BaseApiObject&gt;</code>
125
+ * [.listApplications(request)](#Applications+listApplications) ⇒ <code>Promise.&lt;ListApplicationsResponse&gt;</code>
126
+ * [.deleteApplication(request)](#Applications+deleteApplication) ⇒ <code>Promise.&lt;BaseApiObject&gt;</code>
127
+
128
+ <a name="new_Applications_new"></a>
129
+
130
+ ### new Applications(client)
131
+ Constructs a new Applications object.
132
+
133
+
134
+ | Param | Type | Description |
135
+ | --- | --- | --- |
136
+ | client | <code>FonosterClient</code> | Client object with underlying implementations to make requests to Fonoster's API |
137
+
138
+ **Example**
139
+ ```js
140
+ const SDK = require("@fonoster/sdk");
141
+
142
+ const request = {
143
+ name: "My application",
144
+ type: "PROGRAMMABLE_VOICE",
145
+ appEndpoint: "myapp.mydomain.com",
146
+ textToSpeech: {
147
+ productRef: "tts.google",
148
+ config: {
149
+ voice: "en-US-Casual-K"
150
+ }
151
+ },
152
+ speechToText: {
153
+ productRef: "stt.google",
154
+ config: {
155
+ languageCode: "en-US"
156
+ }
157
+ },
158
+ intelligence: {
159
+ productRef: "nlu.dialogflowcx",
160
+ credentials: {
161
+ apiKey: "your-api-key"
162
+ },
163
+ config: {
164
+ agentId: "your-agent-id"
165
+ }
166
+ }
167
+ };
168
+
169
+ const username = "admin@fonoster.local";
170
+ const password = "changeme";
171
+ const accessKeyId = "WO00000000000000000000000000000000";
172
+
173
+ const client = new SDK.Client({ accessKeyId });
174
+
175
+ client.login(username, password)
176
+ .then(async () => {
177
+ const apps = new SDK.Applications(client);
178
+ const result = await apps.createApplication(request);
179
+ console.log(result); // successful response
180
+ }).catch(console.error); // an error occurred
181
+ ```
182
+ <a name="Applications+createApplication"></a>
183
+
184
+ ### applications.createApplication(request) ⇒ <code>Promise.&lt;CreateAppResponse&gt;</code>
185
+ Creates a new Application in Fonoster. The only required fields are the name and type of the application.
186
+
187
+ **Kind**: instance method of [<code>Applications</code>](#Applications)
188
+ **Returns**: <code>Promise.&lt;CreateAppResponse&gt;</code> - - The response object that contains the reference to the newly created application
189
+
190
+ | Param | Type | Description |
191
+ | --- | --- | --- |
192
+ | request | <code>CreateApplicationRequest</code> | The request object that contains the necessary information to create a new application |
193
+ | request.name | <code>string</code> | The name of the application |
194
+ | request.type | <code>ApplicationType</code> | The type of application (e.g., PROGRAMMABLE_VOICE) |
195
+ | request.appEndpoint | <code>string</code> | The endpoint where the application is hosted |
196
+ | request.textToSpeech | <code>TextToSpeech</code> | The text-to-speech configuration |
197
+ | request.textToSpeech.productRef | <code>string</code> | The product reference of the text-to-speech engine (e.g., tts.google) |
198
+ | request.textToSpeech.config | <code>object</code> | The configuration object for the text-to-speech engine (e.g., { voice: "en-US-Casual-K" }) |
199
+ | request.speechToText | <code>SpeechToText</code> | The speech-to-text configuration |
200
+ | request.speechToText.productRef | <code>string</code> | The product reference of the speech-to-text engine (e.g., stt.google) |
201
+ | request.speechToText.config | <code>object</code> | The configuration object for the speech-to-text engine (e.g., { languageCode: "en-US" }) |
202
+ | request.intelligence | <code>Intelligence</code> | The intelligence configuration |
203
+ | request.intelligence.productRef | <code>string</code> | The product reference of the intelligence engine (e.g., nlu.dialogflowcx) |
204
+ | request.intelligence.credentials | <code>object</code> | The credentials object for the intelligence engine (e.g., { apiKey: "your-api-key" }) |
205
+ | request.intelligence.config | <code>object</code> | The configuration object for the intelligence engine (e.g., { agentId: "your-agent-id" }) |
206
+
207
+ **Example**
208
+ ```js
209
+ const request = {
210
+ name: "My application",
211
+ type: "PROGRAMMABLE_VOICE",
212
+ appEndpoint: "myapp.mydomain.com",
213
+ textToSpeech: {
214
+ productRef: "tts.google",
215
+ config: {
216
+ voice: "en-US-Casual-K"
217
+ }
218
+ },
219
+ speechToText: {
220
+ productRef: "stt.google",
221
+ config: {
222
+ languageCode: "en-US"
223
+ }
224
+ },
225
+ intelligence: {
226
+ productRef: "nlu.dialogflowcx",
227
+ credentials: {
228
+ apiKey: "your-api-key"
229
+ },
230
+ config: {
231
+ agentId: "your-agent-id"
232
+ }
233
+ }
234
+ };
235
+
236
+ const apps = new SDK.Applications(client); // Existing client object
237
+
238
+ apps.createApplication(request)
239
+ .then(console.log) // successful response
240
+ .catch(console.error); // an error occurred
241
+ ```
242
+ <a name="Applications+getApplication"></a>
243
+
244
+ ### applications.getApplication(request) ⇒ <code>Promise.&lt;Application&gt;</code>
245
+ Retrieves an existing application from Fonoster.
246
+
247
+ **Kind**: instance method of [<code>Applications</code>](#Applications)
248
+ **Returns**: <code>Promise.&lt;Application&gt;</code> - - The response object that contains the application information
249
+
250
+ | Param | Type | Description |
251
+ | --- | --- | --- |
252
+ | request | <code>GetApplicationRequest</code> | The request object that contains the necessary information to retrieve an application |
253
+ | request.ref | <code>string</code> | The reference of the application to retrieve |
254
+
255
+ **Example**
256
+ ```js
257
+ const request = {
258
+ ref: "00000000-0000-0000-0000-000000000000"
259
+ };
260
+
261
+ const apps = new SDK.Applications(client); // Existing client object
262
+
263
+ apps.getApplication(request)
264
+ .then(console.log) // successful response
265
+ .catch(console.error); // an error occurred
266
+ ```
267
+ <a name="Applications+updateApplication"></a>
268
+
269
+ ### applications.updateApplication(request) ⇒ <code>Promise.&lt;BaseApiObject&gt;</code>
270
+ Updates an existing application in Fonoster.
271
+
272
+ **Kind**: instance method of [<code>Applications</code>](#Applications)
273
+ **Returns**: <code>Promise.&lt;BaseApiObject&gt;</code> - - The response object that contains the reference to the updated application
274
+
275
+ | Param | Type | Description |
276
+ | --- | --- | --- |
277
+ | request | <code>UpdateApplicationRequest</code> | The request object that contains the necessary information to update an application |
278
+ | request.ref | <code>string</code> | The reference of the application to update |
279
+ | request.name | <code>string</code> | The name of the application |
280
+ | request.appEndpoint | <code>string</code> | The endpoint where the application is hosted |
281
+ | request.textToSpeech | <code>TextToSpeech</code> | The text-to-speech configuration |
282
+ | request.textToSpeech.productRef | <code>string</code> | The product reference of the text-to-speech engine (e.g., tts.google) |
283
+ | request.textToSpeech.config | <code>object</code> | The configuration object for the text-to-speech engine (e.g., { voice: "en-US-Casual-K" }) |
284
+ | request.speechToText | <code>SpeechToText</code> | The speech-to-text configuration |
285
+ | request.speechToText.productRef | <code>string</code> | The product reference of the speech-to-text engine (e.g., stt.google) |
286
+ | request.speechToText.config | <code>object</code> | The configuration object for the speech-to-text engine (e.g., { languageCode: "en-US" }) |
287
+ | request.intelligence | <code>Intelligence</code> | The intelligence configuration |
288
+ | request.intelligence.productRef | <code>string</code> | The product reference of the intelligence engine (e.g., nlu.dialogflowcx) |
289
+ | request.intelligence.credentials | <code>object</code> | The credentials object for the intelligence engine (e.g., { apiKey: "your-api-key" }) |
290
+ | request.intelligence.config | <code>object</code> | The configuration object for the intelligence engine (e.g., { agentId: "your-agent-id" }) |
291
+
292
+ **Example**
293
+ ```js
294
+ const request = {
295
+ ref: "00000000-0000-0000-0000-000000000000",
296
+ name: "My application",
297
+ appEndpoint: "myapp.mydomain.com"
298
+ }
299
+
300
+ const apps = new SDK.Applications(client); // Existing client object
301
+
302
+ apps.updateApplication(request)
303
+ .then(console.log) // successful response
304
+ .catch(console.error); // an error occurred
305
+ ```
306
+ <a name="Applications+listApplications"></a>
307
+
308
+ ### applications.listApplications(request) ⇒ <code>Promise.&lt;ListApplicationsResponse&gt;</code>
309
+ Retrieves a list of applications from Fonoster.
310
+
311
+ **Kind**: instance method of [<code>Applications</code>](#Applications)
312
+ **Returns**: <code>Promise.&lt;ListApplicationsResponse&gt;</code> - - The response object that contains the list of applications
313
+
314
+ | Param | Type | Description |
315
+ | --- | --- | --- |
316
+ | request | <code>ListApplicationsRequest</code> | The request object that contains the necessary information to retrieve a list of applications |
317
+ | request.pageSize | <code>number</code> | The number of applications to retrieve |
318
+ | request.pageToken | <code>string</code> | The token to retrieve the next page of applications |
319
+
320
+ **Example**
321
+ ```js
322
+ const request = {
323
+ pageSize: 10,
324
+ pageToken: "00000000-0000-0000-0000-000000000000"
325
+ };
326
+
327
+ const apps = new SDK.Applications(client); // Existing client object
328
+
329
+ apps.listApplications(request)
330
+ .then(console.log) // successful response
331
+ .catch(console.error); // an error occurred
332
+ ```
333
+ <a name="Applications+deleteApplication"></a>
334
+
335
+ ### applications.deleteApplication(request) ⇒ <code>Promise.&lt;BaseApiObject&gt;</code>
336
+ Deletes an existing application from Fonoster.
337
+ Note that this operation is irreversible.
338
+
339
+ **Kind**: instance method of [<code>Applications</code>](#Applications)
340
+ **Returns**: <code>Promise.&lt;BaseApiObject&gt;</code> - - The response object that contains the reference to the deleted application
341
+
342
+ | Param | Type | Description |
343
+ | --- | --- | --- |
344
+ | request | <code>DeleteApplicationRequest</code> | The request object that contains the necessary information to delete an application |
345
+ | request.ref | <code>string</code> | The reference of the application to delete |
346
+
347
+ **Example**
348
+ ```js
349
+ const request = {
350
+ ref: "00000000-0000-0000-0000-000000000000"
351
+ };
352
+
353
+ const apps = new SDK.Applications(client); // Existing client object
354
+
355
+ apps.deleteApplication(request)
356
+ .then(console.log) // successful response
357
+ .catch(console.error); // an error occurred
358
+ ```
2
359
 
3
- This module is part of the \[Fonoster\](https://fonoster.com) project. By itself, it does not do much. It is intended to be used as a dependency for other modules. For more information about the project, please visit \[https://github.com/fonoster/fonoster\](https://github.com/fonoster/fonoster).a](../apiserver/README.md)
@@ -0,0 +1,206 @@
1
+ import { Application, BaseApiObject, CreateApplicationRequest, CreateApplicationResponse, ListApplicationsRequest, ListApplicationsResponse, UpdateApplicationRequest } from "@fonoster/common";
2
+ import { FonosterClient } from "./client/types";
3
+ /**
4
+ * @classdesc Fonoster Applications, part of the Fonoster Voice Subsystem,
5
+ * allow you to create, update, retrieve, and delete Voice Applications.
6
+ * Note that an active Fonoster deployment is required.
7
+ *
8
+ * @example
9
+ *
10
+ * const SDK = require("@fonoster/sdk");
11
+ *
12
+ * const request = {
13
+ * name: "My application",
14
+ * type: "PROGRAMMABLE_VOICE",
15
+ * appEndpoint: "myapp.mydomain.com",
16
+ * textToSpeech: {
17
+ * productRef: "tts.google",
18
+ * config: {
19
+ * voice: "en-US-Casual-K"
20
+ * }
21
+ * },
22
+ * speechToText: {
23
+ * productRef: "stt.google",
24
+ * config: {
25
+ * languageCode: "en-US"
26
+ * }
27
+ * },
28
+ * intelligence: {
29
+ * productRef: "nlu.dialogflowcx",
30
+ * credentials: {
31
+ * apiKey: "your-api-key"
32
+ * },
33
+ * config: {
34
+ * agentId: "your-agent-id"
35
+ * }
36
+ * }
37
+ * };
38
+ *
39
+ * const username = "admin@fonoster.local";
40
+ * const password = "changeme";
41
+ * const accessKeyId = "WO00000000000000000000000000000000";
42
+ *
43
+ * const client = new SDK.Client({ accessKeyId });
44
+ *
45
+ * client.login(username, password)
46
+ * .then(async () => {
47
+ * const apps = new SDK.Applications(client);
48
+ * const result = await apps.createApplication(request);
49
+ * console.log(result); // successful response
50
+ * }).catch(console.error); // an error occurred
51
+ */
52
+ declare class Applications {
53
+ private client;
54
+ /**
55
+ * Constructs a new Applications object.
56
+ *
57
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
58
+ * @see AbstractClient
59
+ * @see FonosterClient
60
+ */
61
+ constructor(client: FonosterClient);
62
+ /**
63
+ * Creates a new Application in Fonoster. The only required fields are the name and type of the application.
64
+ *
65
+ * @param {CreateApplicationRequest} request - The request object that contains the necessary information to create a new application
66
+ * @param {string} request.name - The name of the application
67
+ * @param {ApplicationType} request.type - The type of application (e.g., PROGRAMMABLE_VOICE)
68
+ * @param {string} request.appEndpoint - The endpoint where the application is hosted
69
+ * @param {TextToSpeech} request.textToSpeech - The text-to-speech configuration
70
+ * @param {string} request.textToSpeech.productRef - The product reference of the text-to-speech engine (e.g., tts.google)
71
+ * @param {object} request.textToSpeech.config - The configuration object for the text-to-speech engine (e.g., { voice: "en-US-Casual-K" })
72
+ * @param {SpeechToText} request.speechToText - The speech-to-text configuration
73
+ * @param {string} request.speechToText.productRef - The product reference of the speech-to-text engine (e.g., stt.google)
74
+ * @param {object} request.speechToText.config - The configuration object for the speech-to-text engine (e.g., { languageCode: "en-US" })
75
+ * @param {Intelligence} request.intelligence - The intelligence configuration
76
+ * @param {string} request.intelligence.productRef - The product reference of the intelligence engine (e.g., nlu.dialogflowcx)
77
+ * @param {object} request.intelligence.credentials - The credentials object for the intelligence engine (e.g., { apiKey: "your-api-key" })
78
+ * @param {object} request.intelligence.config - The configuration object for the intelligence engine (e.g., { agentId: "your-agent-id" })
79
+ * @return {Promise<CreateAppResponse>} - The response object that contains the reference to the newly created application
80
+ * @example
81
+ *
82
+ * const request = {
83
+ * name: "My application",
84
+ * type: "PROGRAMMABLE_VOICE",
85
+ * appEndpoint: "myapp.mydomain.com",
86
+ * textToSpeech: {
87
+ * productRef: "tts.google",
88
+ * config: {
89
+ * voice: "en-US-Casual-K"
90
+ * }
91
+ * },
92
+ * speechToText: {
93
+ * productRef: "stt.google",
94
+ * config: {
95
+ * languageCode: "en-US"
96
+ * }
97
+ * },
98
+ * intelligence: {
99
+ * productRef: "nlu.dialogflowcx",
100
+ * credentials: {
101
+ * apiKey: "your-api-key"
102
+ * },
103
+ * config: {
104
+ * agentId: "your-agent-id"
105
+ * }
106
+ * }
107
+ * };
108
+ *
109
+ * const apps = new SDK.Applications(client); // Existing client object
110
+ *
111
+ * apps.createApplication(request)
112
+ * .then(console.log) // successful response
113
+ * .catch(console.error); // an error occurred
114
+ */
115
+ createApplication(request: CreateApplicationRequest): Promise<CreateApplicationResponse>;
116
+ /**
117
+ * Retrieves an existing application from Fonoster.
118
+ *
119
+ * @param {string} ref - The reference of the application to retrieve
120
+ * @return {Promise<Application>} - The response object that contains the application information
121
+ * @example
122
+ *
123
+ * const request = {
124
+ * ref: "00000000-0000-0000-0000-000000000000"
125
+ * };
126
+ *
127
+ * const apps = new SDK.Applications(client); // Existing client object
128
+ *
129
+ * apps.getApplication(request)
130
+ * .then(console.log) // successful response
131
+ * .catch(console.error); // an error occurred
132
+ */
133
+ getApplication(ref: string): Promise<Application>;
134
+ /**
135
+ * Updates an existing application in Fonoster.
136
+ *
137
+ * @param {UpdateApplicationRequest} request - The request object that contains the necessary information to update an application
138
+ * @param {string} request.ref - The reference of the application to update
139
+ * @param {string} request.name - The name of the application
140
+ * @param {string} request.appEndpoint - The endpoint where the application is hosted
141
+ * @param {TextToSpeech} request.textToSpeech - The text-to-speech configuration
142
+ * @param {string} request.textToSpeech.productRef - The product reference of the text-to-speech engine (e.g., tts.google)
143
+ * @param {object} request.textToSpeech.config - The configuration object for the text-to-speech engine (e.g., { voice: "en-US-Casual-K" })
144
+ * @param {SpeechToText} request.speechToText - The speech-to-text configuration
145
+ * @param {string} request.speechToText.productRef - The product reference of the speech-to-text engine (e.g., stt.google)
146
+ * @param {object} request.speechToText.config - The configuration object for the speech-to-text engine (e.g., { languageCode: "en-US" })
147
+ * @param {Intelligence} request.intelligence - The intelligence configuration
148
+ * @param {string} request.intelligence.productRef - The product reference of the intelligence engine (e.g., nlu.dialogflowcx)
149
+ * @param {object} request.intelligence.credentials - The credentials object for the intelligence engine (e.g., { apiKey: "your-api-key" })
150
+ * @param {object} request.intelligence.config - The configuration object for the intelligence engine (e.g., { agentId: "your-agent-id" })
151
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated application
152
+ * @example
153
+ *
154
+ * const request = {
155
+ * ref: "00000000-0000-0000-0000-000000000000",
156
+ * name: "My application",
157
+ * appEndpoint: "myapp.mydomain.com"
158
+ * }
159
+ *
160
+ * const apps = new SDK.Applications(client); // Existing client object
161
+ *
162
+ * apps.updateApplication(request)
163
+ * .then(console.log) // successful response
164
+ * .catch(console.error); // an error occurred
165
+ */
166
+ updateApplication(request: UpdateApplicationRequest): Promise<BaseApiObject>;
167
+ /**
168
+ * Retrieves a list of applications from Fonoster.
169
+ *
170
+ * @param {ListApplicationsRequest} request - The request object that contains the necessary information to retrieve a list of applications
171
+ * @param {number} request.pageSize - The number of applications to retrieve
172
+ * @param {string} request.pageToken - The token to retrieve the next page of applications
173
+ * @return {Promise<ListApplicationsResponse>} - The response object that contains the list of applications
174
+ * @example
175
+ *
176
+ * const request = {
177
+ * pageSize: 10,
178
+ * pageToken: "00000000-0000-0000-0000-000000000000"
179
+ * };
180
+ *
181
+ * const apps = new SDK.Applications(client); // Existing client object
182
+ *
183
+ * apps.listApplications(request)
184
+ * .then(console.log) // successful response
185
+ * .catch(console.error); // an error occurred
186
+ */
187
+ listApplications(request: ListApplicationsRequest): Promise<ListApplicationsResponse>;
188
+ /**
189
+ * Deletes an existing application from Fonoster.
190
+ * Note that this operation is irreversible.
191
+ *
192
+ * @param {string} ref - The reference of the application to delete
193
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted application
194
+ * @example
195
+ *
196
+ * const ref = "00000000-0000-0000-0000-000000000000"
197
+ *
198
+ * const apps = new SDK.Applications(client); // Existing client object
199
+ *
200
+ * apps.deleteApplication(ref)
201
+ * .then(console.log) // successful response
202
+ * .catch(console.error); // an error occurred
203
+ */
204
+ deleteApplication(ref: string): Promise<BaseApiObject>;
205
+ }
206
+ export { Applications };