@fonoster/sdk 0.6.1 → 0.6.2

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 (70) hide show
  1. package/README.md +2301 -169
  2. package/dist/node/Acls.d.ts +150 -0
  3. package/dist/node/Acls.js +227 -0
  4. package/dist/node/Agents.d.ts +163 -0
  5. package/dist/node/Agents.js +211 -0
  6. package/dist/node/ApiKeys.d.ts +120 -0
  7. package/dist/node/ApiKeys.js +178 -0
  8. package/dist/node/Applications.d.ts +31 -27
  9. package/dist/node/Applications.js +30 -26
  10. package/dist/node/Calls.d.ts +109 -0
  11. package/dist/node/Calls.js +165 -0
  12. package/dist/node/Credentials.d.ts +148 -0
  13. package/dist/node/Credentials.js +194 -0
  14. package/dist/node/Domains.d.ts +152 -0
  15. package/dist/node/Domains.js +198 -0
  16. package/dist/node/Numbers.d.ts +152 -0
  17. package/dist/node/Numbers.js +198 -0
  18. package/dist/node/Secrets.d.ts +144 -0
  19. package/dist/node/Secrets.js +190 -0
  20. package/dist/node/Trunks.d.ts +181 -0
  21. package/dist/node/Trunks.js +275 -0
  22. package/dist/node/Users.d.ts +132 -0
  23. package/dist/node/Users.js +169 -0
  24. package/dist/node/Workspaces.d.ts +195 -0
  25. package/dist/node/Workspaces.js +265 -0
  26. package/dist/node/client/AbstractClient.d.ts +16 -2
  27. package/dist/node/client/AbstractClient.js +0 -1
  28. package/dist/node/client/Client.d.ts +8 -0
  29. package/dist/node/client/Client.js +48 -0
  30. package/dist/node/client/types/AclsClient.d.ts +10 -0
  31. package/dist/node/client/types/AgentsClient.d.ts +10 -0
  32. package/dist/node/client/types/AgentsClient.js +2 -0
  33. package/dist/node/client/types/ApplicationsClient.d.ts +10 -0
  34. package/dist/node/client/types/ApplicationsClient.js +2 -0
  35. package/dist/node/client/types/CallsClient.d.ts +8 -0
  36. package/dist/node/client/types/CallsClient.js +2 -0
  37. package/dist/node/client/types/CredentialsClient.d.ts +10 -0
  38. package/dist/node/client/types/CredentialsClient.js +2 -0
  39. package/dist/node/client/types/DomainsClient.d.ts +10 -0
  40. package/dist/node/client/types/DomainsClient.js +2 -0
  41. package/dist/node/client/types/FonosterClient.d.ts +27 -0
  42. package/dist/node/client/types/FonosterClient.js +2 -0
  43. package/dist/node/client/types/IdentityClient.d.ts +24 -0
  44. package/dist/node/client/types/IdentityClient.js +2 -0
  45. package/dist/node/client/types/NumbersClient.d.ts +10 -0
  46. package/dist/node/client/types/NumbersClient.js +2 -0
  47. package/dist/node/client/types/SecretsClient.d.ts +10 -0
  48. package/dist/node/client/types/SecretsClient.js +2 -0
  49. package/dist/node/client/types/TrunksClient.d.ts +10 -0
  50. package/dist/node/client/types/TrunksClient.js +2 -0
  51. package/dist/node/client/types/common.d.ts +4 -0
  52. package/dist/node/client/types/common.js +2 -0
  53. package/dist/node/client/types/index.d.ts +6 -0
  54. package/dist/node/client/types/index.js +40 -0
  55. package/dist/node/generated/node/identity_pb.js +9 -9
  56. package/dist/node/generated/node/trunks_grpc_pb.js +8 -8
  57. package/dist/node/generated/node/trunks_pb.js +25 -25
  58. package/dist/node/generated/web/TrunksServiceClientPb.ts +5 -5
  59. package/dist/node/generated/web/identity_pb.d.ts +5 -5
  60. package/dist/node/generated/web/identity_pb.js +9 -9
  61. package/dist/node/generated/web/trunks_pb.d.ts +9 -9
  62. package/dist/node/generated/web/trunks_pb.js +25 -25
  63. package/dist/node/node.d.ts +11 -0
  64. package/dist/node/node.js +11 -0
  65. package/dist/node/tsconfig.node.tsbuildinfo +1 -1
  66. package/dist/web/fonoster.min.js +1 -1
  67. package/dist/web/index.esm.js +1 -1
  68. package/package.json +3 -3
  69. package/dist/node/client/types.d.ts +0 -26
  70. /package/dist/node/client/{types.js → types/AclsClient.js} +0 -0
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Users = void 0;
4
+ const makeRpcRequest_1 = require("./client/makeRpcRequest");
5
+ const identity_pb_1 = require("./generated/node/identity_pb");
6
+ /**
7
+ * @classdesc Fonoster Users, part of the Fonoster Identity subsystem,
8
+ * allows you to create, update, retrieve, and delete a Users in the system.
9
+ * Note that an active Fonoster deployment is required.
10
+ *
11
+ * @example
12
+ *
13
+ * const SDK = require("@fonoster/sdk");
14
+ *
15
+ * async function main(request) {
16
+ * const apiKey = "your-api-key";
17
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
18
+ *
19
+ * try {
20
+ * const client = SDK.Client({ accessKeyId });
21
+ * await client.loginWithApiKey(apiKey);
22
+ *
23
+ * const users = new SDK.Users(client);
24
+ * const response = await users.createUser(request);
25
+ *
26
+ * console.log(response); // successful response
27
+ * } catch (e) {
28
+ * console.error(e); // an error occurred
29
+ * }
30
+ * }
31
+ *
32
+ * const request = {
33
+ * name: "John Doe",
34
+ * email: "john.doe@example.com",
35
+ * password: "password",
36
+ * avatar: "https://example.com/avatar.jpg"
37
+ * };
38
+ *
39
+ * main(request).catch(console.error);
40
+ */
41
+ class Users {
42
+ client;
43
+ /**
44
+ * Constructs a new Users object.
45
+ *
46
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
47
+ * @see AbstractClient
48
+ * @see FonosterClient
49
+ */
50
+ constructor(client) {
51
+ this.client = client;
52
+ }
53
+ /**
54
+ * Creates a new User in the Workspace.
55
+ *
56
+ * @param {CreateUserRequest} request - The request object that contains the necessary information to create a new User
57
+ * @param {string} request.name - The name of the User
58
+ * @param {string} request.email - The email of the User
59
+ * @param {string} request.password - The password of the User
60
+ * @param {string} request.avatar - The avatar of the User
61
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created User
62
+ * @example
63
+ *
64
+ * const request = {
65
+ * name: "John Doe",
66
+ * email: "john.doe@example.com",
67
+ * password: "password",
68
+ * avatar: "https://example.com/avatar.jpg"
69
+ * };
70
+ *
71
+ * const users = new SDK.Users(client); // Existing client object
72
+ *
73
+ * users.createUser(request)
74
+ * .then(console.log) // successful response
75
+ * .catch(console.error); // an error occurred
76
+ */
77
+ async createUser(request) {
78
+ const client = this.client.getIdentityClient();
79
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
80
+ method: client.createUser.bind(client),
81
+ requestPBObjectConstructor: identity_pb_1.CreateUserRequest,
82
+ metadata: this.client.getMetadata(),
83
+ request
84
+ });
85
+ }
86
+ /**
87
+ * Retrieves an existing User in the Workspace.
88
+ *
89
+ * @param {string} ref - The reference of the User to retrieve
90
+ * @return {Promise<Acl>} - The response object that contains the User
91
+ * @example
92
+ *
93
+ * const ref = "00000000-0000-0000-0000-000000000000"
94
+ *
95
+ * const users = new SDK.Users(client); // Existing client object
96
+ *
97
+ * users.getUser(ref)
98
+ * .then(console.log) // successful response
99
+ * .catch(console.error); // an error occurred
100
+ */
101
+ async getUser(ref) {
102
+ const client = this.client.getIdentityClient();
103
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
104
+ method: client.getUser.bind(client),
105
+ requestPBObjectConstructor: identity_pb_1.GetUserRequest,
106
+ metadata: this.client.getMetadata(),
107
+ request: { ref }
108
+ });
109
+ }
110
+ /**
111
+ * Updates an existing User in the Workspace.
112
+ *
113
+ * @param {UpdateUserRequest} request - The request object that contains the necessary information to update a User
114
+ * @param {string} request.ref - The reference of the User to update
115
+ * @param {string} request.name - The name of the User
116
+ * @param {string} request.password - The password of the User
117
+ * @param {string} request.avatar - The avatar of the User
118
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated User
119
+ * @example
120
+ *
121
+ * const request = {
122
+ * ref: "00000000-0000-0000-0000-000000000000",
123
+ * name: "John Doe",
124
+ * password: "password",
125
+ * avatar: "https://example.com/avatar.jpg"
126
+ * };
127
+ *
128
+ * const users = new SDK.Users(client); // Existing client object
129
+ *
130
+ * users.updateUser(request)
131
+ * .then(console.log) // successful response
132
+ * .catch(console.error); // an error occurred
133
+ */
134
+ async updateUser(request) {
135
+ const client = this.client.getIdentityClient();
136
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
137
+ method: client.updateUser.bind(client),
138
+ requestPBObjectConstructor: identity_pb_1.UpdateUserRequest,
139
+ metadata: this.client.getMetadata(),
140
+ request
141
+ });
142
+ }
143
+ /**
144
+ * Deletes an existing User from Fonoster.
145
+ * Note that this operation is irreversible.
146
+ *
147
+ * @param {string} ref - The reference of the User to delete
148
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted User
149
+ * @example
150
+ *
151
+ * const ref = "00000000-0000-0000-0000-000000000000"
152
+ *
153
+ * const users = new SDK.Users(client); // Existing client object
154
+ *
155
+ * users.deleteUser(ref)
156
+ * .then(console.log) // successful response
157
+ * .catch(console.error); // an error occurred
158
+ */
159
+ async deleteUser(ref) {
160
+ const client = this.client.getIdentityClient();
161
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
162
+ method: client.deleteUser.bind(client),
163
+ requestPBObjectConstructor: identity_pb_1.DeleteUserRequest,
164
+ metadata: this.client.getMetadata(),
165
+ request: { ref }
166
+ });
167
+ }
168
+ }
169
+ exports.Users = Users;
@@ -0,0 +1,195 @@
1
+ import { BaseApiObject, CreateWorkspaceRequest, InviteUserToWorkspaceRequest, ListWorkspacesResponse, RemoveUserFromWorkspaceResponse, ResendWorkspaceMembershipInvitationResponse, UpdateWorkspaceRequest, Workspace } from "@fonoster/types";
2
+ import { FonosterClient } from "./client/types";
3
+ /**
4
+ * @classdesc Fonoster Workspaces, part of the Fonoster Identity subsystem,
5
+ * allows you to create, update, retrieve, and delete Workspaces in the system.
6
+ * Note that an active Fonoster deployment is required.
7
+ *
8
+ * @example
9
+ *
10
+ * const SDK = require("@fonoster/sdk");
11
+ *
12
+ * async function main(request) {
13
+ * const apiKey = "your-api-key";
14
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
15
+ *
16
+ * try {
17
+ * const client = SDK.Client({ accessKeyId });
18
+ * await client.loginWithApiKey(apiKey);
19
+ *
20
+ * const workspaces = new SDK.Workspaces(client);
21
+ * const response = await workspaces.createWorkspace(request);
22
+ *
23
+ * console.log(response); // successful response
24
+ * } catch (e) {
25
+ * console.error(e); // an error occurred
26
+ * }
27
+ * }
28
+ *
29
+ * const request = {
30
+ * name: "My Workspace"
31
+ * };
32
+ *
33
+ * main(request).catch(console.error);
34
+ */
35
+ declare class Workspaces {
36
+ private client;
37
+ /**
38
+ * Constructs a new Workspaces object.
39
+ *
40
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
41
+ * @see AbstractClient
42
+ * @see FonosterClient
43
+ */
44
+ constructor(client: FonosterClient);
45
+ /**
46
+ * Creates a new Workspace in the system.
47
+ *
48
+ * @param {CreateWorkspaceRequest} request - The request object that contains the necessary information to create a new Workspace
49
+ * @param {string} request.name - The name of the Workspace
50
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Workspace
51
+ * @example
52
+ *
53
+ * const request = {
54
+ * name: "My Workspace"
55
+ * };
56
+ *
57
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
58
+ *
59
+ * workspaces.createWorkspace(request)
60
+ * .then(console.log) // successful response
61
+ * .catch(console.error); // an error occurred
62
+ */
63
+ createWorkspace(request: CreateWorkspaceRequest): Promise<BaseApiObject>;
64
+ /**
65
+ * Retrieves an existing Workspace in the system.
66
+ *
67
+ * @param {string} ref - The reference of the Workspace to retrieve
68
+ * @return {Promise<Acl>} - The response object that contains the Workspace
69
+ * @example
70
+ *
71
+ * const ref = "00000000-0000-0000-0000-000000000000"
72
+ *
73
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
74
+ *
75
+ * workspaces.getWorkspace(ref)
76
+ * .then(console.log) // successful response
77
+ * .catch(console.error); // an error occurred
78
+ */
79
+ getWorkspace(ref: string): Promise<Workspace>;
80
+ /**
81
+ * Updates an existing Workspace in the system.
82
+ *
83
+ * @param {UpdateWorkspaceRequest} request - The request object that contains the necessary information to update a Workspace
84
+ * @param {string} request.ref - The reference of the Workspace to update
85
+ * @param {string} request.name - The name of the Workspace
86
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Workspace
87
+ * @example
88
+ *
89
+ * const request = {
90
+ * ref: "00000000-0000-0000-0000-000000000000",
91
+ * name: "My Workspace"
92
+ * };
93
+ *
94
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
95
+ *
96
+ * workspaces.updateWorkspace(request)
97
+ * .then(console.log) // successful response
98
+ * .catch(console.error); // an error occurred
99
+ */
100
+ updateWorkspace(request: UpdateWorkspaceRequest): Promise<BaseApiObject>;
101
+ /**
102
+ * Deletes an existing Workspace from Fonoster.
103
+ * Note that this operation is irreversible.
104
+ *
105
+ * @param {string} ref - The reference of the Workspace to delete
106
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Workspace
107
+ * @example
108
+ *
109
+ * const ref = "00000000-0000-0000-0000-000000000000"
110
+ *
111
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
112
+ *
113
+ * workspaces.deleteWorkspace(ref)
114
+ * .then(console.log) // successful response
115
+ * .catch(console.error); // an error occurred
116
+ */
117
+ deleteWorkspace(ref: string): Promise<BaseApiObject>;
118
+ /**
119
+ * Retrieves a list of Workspaces from a Workspace.
120
+ *
121
+ * @param {ListWorkspacesRequest} request - The request object that contains the necessary information to retrieve a list of Workspaces
122
+ * @param {number} request.pageSize - The workspace of Workspaces to retrieve
123
+ * @param {string} request.pageToken - The token to retrieve the next page of Workspaces
124
+ * @return {Promise<ListWorkspacesResponse>} - The response object that contains the list of Workspaces
125
+ * @example
126
+ *
127
+ * const request = {
128
+ * pageSize: 10,
129
+ * pageToken: "00000000-0000-0000-0000-000000000000"
130
+ * };
131
+ *
132
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
133
+ *
134
+ * workspaces.listWorkspaces(request)
135
+ * .then(console.log) // successful response
136
+ * .catch(console.error); // an error occurred
137
+ */
138
+ listWorkspaces(): Promise<ListWorkspacesResponse>;
139
+ /**
140
+ * Invites a User to a Workspace.
141
+ *
142
+ * @param {InviteUserToWorkspaceRequest} request - The request object that contains the necessary information to invite a User to a Workspace
143
+ * @param {string} request.workspaceRef - The reference of the Workspace to invite the User to
144
+ * @param {string} request.email - The email of the User to invite
145
+ * @param {string} request.password - Temporary password for the User. Leave empty to generate a random password
146
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the invitation
147
+ * @example
148
+ *
149
+ * const request = {
150
+ * workspaceRef: "00000000-0000-0000-0000-000000000000",
151
+ * email: "jane.doe@example.com",
152
+ * role: "WORKSPACE_MEMBER",
153
+ * };
154
+ *
155
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
156
+ *
157
+ * workspaces.inviteUserToWorkspace(request)
158
+ * .then(console.log) // successful response
159
+ * .catch(console.error); // an error occurred
160
+ */
161
+ inviteUserToWorkspace(request: InviteUserToWorkspaceRequest): Promise<BaseApiObject>;
162
+ /**
163
+ * Resend a Workspace membership invitation.
164
+ *
165
+ * @param {string} userRef - The reference to the user to resend the invitation
166
+ * @return {Promise<ResendWorkspaceMembershipInvitationResponse>} - The response object that contains the reference to the invitation
167
+ * @example
168
+ *
169
+ * const userRef: "00000000-0000-0000-0000-000000000000";
170
+ *
171
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
172
+ *
173
+ * workspaces.resendWorkspaceMembershipInvitation(request)
174
+ * .then(console.log) // successful response
175
+ * .catch(console.error); // an error occurred
176
+ */
177
+ resendWorkspaceMembershipInvitation(userRef: string): Promise<ResendWorkspaceMembershipInvitationResponse>;
178
+ /**
179
+ * Removes a User from a Workspace.
180
+ *
181
+ * @param {string} userRef - The reference of the User to remove from the Workspace
182
+ * @return {Promise<RemoveUserFromWorkspaceResponse>} - The response object that contains the reference to the removed User
183
+ * @example
184
+ *
185
+ * const userRef = "00000000-0000-0000-0000-000000000000";
186
+ *
187
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
188
+ *
189
+ * workspaces.removeUserFromWorkspace(userRef)
190
+ * .then(console.log) // successful response
191
+ * .catch(console.error); // an error occurred
192
+ */
193
+ removeUserFromWorkspace(userRef: string): Promise<RemoveUserFromWorkspaceResponse>;
194
+ }
195
+ export { Workspaces };
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Workspaces = void 0;
4
+ const makeRpcRequest_1 = require("./client/makeRpcRequest");
5
+ const identity_pb_1 = require("./generated/node/identity_pb");
6
+ /**
7
+ * @classdesc Fonoster Workspaces, part of the Fonoster Identity subsystem,
8
+ * allows you to create, update, retrieve, and delete Workspaces in the system.
9
+ * Note that an active Fonoster deployment is required.
10
+ *
11
+ * @example
12
+ *
13
+ * const SDK = require("@fonoster/sdk");
14
+ *
15
+ * async function main(request) {
16
+ * const apiKey = "your-api-key";
17
+ * const accessKeyId = "00000000-0000-0000-0000-000000000000";
18
+ *
19
+ * try {
20
+ * const client = SDK.Client({ accessKeyId });
21
+ * await client.loginWithApiKey(apiKey);
22
+ *
23
+ * const workspaces = new SDK.Workspaces(client);
24
+ * const response = await workspaces.createWorkspace(request);
25
+ *
26
+ * console.log(response); // successful response
27
+ * } catch (e) {
28
+ * console.error(e); // an error occurred
29
+ * }
30
+ * }
31
+ *
32
+ * const request = {
33
+ * name: "My Workspace"
34
+ * };
35
+ *
36
+ * main(request).catch(console.error);
37
+ */
38
+ class Workspaces {
39
+ client;
40
+ /**
41
+ * Constructs a new Workspaces object.
42
+ *
43
+ * @param {FonosterClient} client - Client object with underlying implementations to make requests to Fonoster's API
44
+ * @see AbstractClient
45
+ * @see FonosterClient
46
+ */
47
+ constructor(client) {
48
+ this.client = client;
49
+ }
50
+ /**
51
+ * Creates a new Workspace in the system.
52
+ *
53
+ * @param {CreateWorkspaceRequest} request - The request object that contains the necessary information to create a new Workspace
54
+ * @param {string} request.name - The name of the Workspace
55
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Workspace
56
+ * @example
57
+ *
58
+ * const request = {
59
+ * name: "My Workspace"
60
+ * };
61
+ *
62
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
63
+ *
64
+ * workspaces.createWorkspace(request)
65
+ * .then(console.log) // successful response
66
+ * .catch(console.error); // an error occurred
67
+ */
68
+ async createWorkspace(request) {
69
+ const client = this.client.getIdentityClient();
70
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
71
+ method: client.createWorkspace.bind(client),
72
+ requestPBObjectConstructor: identity_pb_1.CreateWorkspaceRequest,
73
+ metadata: this.client.getMetadata(),
74
+ request
75
+ });
76
+ }
77
+ /**
78
+ * Retrieves an existing Workspace in the system.
79
+ *
80
+ * @param {string} ref - The reference of the Workspace to retrieve
81
+ * @return {Promise<Acl>} - The response object that contains the Workspace
82
+ * @example
83
+ *
84
+ * const ref = "00000000-0000-0000-0000-000000000000"
85
+ *
86
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
87
+ *
88
+ * workspaces.getWorkspace(ref)
89
+ * .then(console.log) // successful response
90
+ * .catch(console.error); // an error occurred
91
+ */
92
+ async getWorkspace(ref) {
93
+ const client = this.client.getIdentityClient();
94
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
95
+ method: client.getWorkspace.bind(client),
96
+ requestPBObjectConstructor: identity_pb_1.GetWorkspaceRequest,
97
+ metadata: this.client.getMetadata(),
98
+ request: { ref }
99
+ });
100
+ }
101
+ /**
102
+ * Updates an existing Workspace in the system.
103
+ *
104
+ * @param {UpdateWorkspaceRequest} request - The request object that contains the necessary information to update a Workspace
105
+ * @param {string} request.ref - The reference of the Workspace to update
106
+ * @param {string} request.name - The name of the Workspace
107
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Workspace
108
+ * @example
109
+ *
110
+ * const request = {
111
+ * ref: "00000000-0000-0000-0000-000000000000",
112
+ * name: "My Workspace"
113
+ * };
114
+ *
115
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
116
+ *
117
+ * workspaces.updateWorkspace(request)
118
+ * .then(console.log) // successful response
119
+ * .catch(console.error); // an error occurred
120
+ */
121
+ async updateWorkspace(request) {
122
+ const client = this.client.getIdentityClient();
123
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
124
+ method: client.updateWorkspace.bind(client),
125
+ requestPBObjectConstructor: identity_pb_1.UpdateWorkspaceRequest,
126
+ metadata: this.client.getMetadata(),
127
+ request
128
+ });
129
+ }
130
+ /**
131
+ * Deletes an existing Workspace from Fonoster.
132
+ * Note that this operation is irreversible.
133
+ *
134
+ * @param {string} ref - The reference of the Workspace to delete
135
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Workspace
136
+ * @example
137
+ *
138
+ * const ref = "00000000-0000-0000-0000-000000000000"
139
+ *
140
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
141
+ *
142
+ * workspaces.deleteWorkspace(ref)
143
+ * .then(console.log) // successful response
144
+ * .catch(console.error); // an error occurred
145
+ */
146
+ async deleteWorkspace(ref) {
147
+ const client = this.client.getIdentityClient();
148
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
149
+ method: client.deleteWorkspace.bind(client),
150
+ requestPBObjectConstructor: identity_pb_1.DeleteWorkspaceRequest,
151
+ metadata: this.client.getMetadata(),
152
+ request: { ref }
153
+ });
154
+ }
155
+ /**
156
+ * Retrieves a list of Workspaces from a Workspace.
157
+ *
158
+ * @param {ListWorkspacesRequest} request - The request object that contains the necessary information to retrieve a list of Workspaces
159
+ * @param {number} request.pageSize - The workspace of Workspaces to retrieve
160
+ * @param {string} request.pageToken - The token to retrieve the next page of Workspaces
161
+ * @return {Promise<ListWorkspacesResponse>} - The response object that contains the list of Workspaces
162
+ * @example
163
+ *
164
+ * const request = {
165
+ * pageSize: 10,
166
+ * pageToken: "00000000-0000-0000-0000-000000000000"
167
+ * };
168
+ *
169
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
170
+ *
171
+ * workspaces.listWorkspaces(request)
172
+ * .then(console.log) // successful response
173
+ * .catch(console.error); // an error occurred
174
+ */
175
+ async listWorkspaces() {
176
+ const applicationsClient = this.client.getIdentityClient();
177
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
178
+ method: applicationsClient.listWorkspaces.bind(applicationsClient),
179
+ requestPBObjectConstructor: identity_pb_1.ListWorkspacesRequest,
180
+ metadata: this.client.getMetadata(),
181
+ request: {},
182
+ repeatableObjectMapping: [["itemsList", identity_pb_1.Workspace]]
183
+ });
184
+ }
185
+ /**
186
+ * Invites a User to a Workspace.
187
+ *
188
+ * @param {InviteUserToWorkspaceRequest} request - The request object that contains the necessary information to invite a User to a Workspace
189
+ * @param {string} request.workspaceRef - The reference of the Workspace to invite the User to
190
+ * @param {string} request.email - The email of the User to invite
191
+ * @param {string} request.password - Temporary password for the User. Leave empty to generate a random password
192
+ * @return {Promise<BaseApiObject>} - The response object that contains the reference to the invitation
193
+ * @example
194
+ *
195
+ * const request = {
196
+ * workspaceRef: "00000000-0000-0000-0000-000000000000",
197
+ * email: "jane.doe@example.com",
198
+ * role: "WORKSPACE_MEMBER",
199
+ * };
200
+ *
201
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
202
+ *
203
+ * workspaces.inviteUserToWorkspace(request)
204
+ * .then(console.log) // successful response
205
+ * .catch(console.error); // an error occurred
206
+ */
207
+ async inviteUserToWorkspace(request) {
208
+ const client = this.client.getIdentityClient();
209
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
210
+ method: client.inviteUserToWorkspace.bind(client),
211
+ requestPBObjectConstructor: identity_pb_1.InviteUserToWorkspaceRequest,
212
+ metadata: this.client.getMetadata(),
213
+ request
214
+ });
215
+ }
216
+ /**
217
+ * Resend a Workspace membership invitation.
218
+ *
219
+ * @param {string} userRef - The reference to the user to resend the invitation
220
+ * @return {Promise<ResendWorkspaceMembershipInvitationResponse>} - The response object that contains the reference to the invitation
221
+ * @example
222
+ *
223
+ * const userRef: "00000000-0000-0000-0000-000000000000";
224
+ *
225
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
226
+ *
227
+ * workspaces.resendWorkspaceMembershipInvitation(request)
228
+ * .then(console.log) // successful response
229
+ * .catch(console.error); // an error occurred
230
+ */
231
+ async resendWorkspaceMembershipInvitation(userRef) {
232
+ const client = this.client.getIdentityClient();
233
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
234
+ method: client.resendWorkspaceMembershipInvitation.bind(client),
235
+ requestPBObjectConstructor: identity_pb_1.ResendWorkspaceMembershipInvitationRequest,
236
+ metadata: this.client.getMetadata(),
237
+ request: { userRef }
238
+ });
239
+ }
240
+ /**
241
+ * Removes a User from a Workspace.
242
+ *
243
+ * @param {string} userRef - The reference of the User to remove from the Workspace
244
+ * @return {Promise<RemoveUserFromWorkspaceResponse>} - The response object that contains the reference to the removed User
245
+ * @example
246
+ *
247
+ * const userRef = "00000000-0000-0000-0000-000000000000";
248
+ *
249
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
250
+ *
251
+ * workspaces.removeUserFromWorkspace(userRef)
252
+ * .then(console.log) // successful response
253
+ * .catch(console.error); // an error occurred
254
+ */
255
+ async removeUserFromWorkspace(userRef) {
256
+ const client = this.client.getIdentityClient();
257
+ return await (0, makeRpcRequest_1.makeRpcRequest)({
258
+ method: client.removeUserFromWorkspace.bind(client),
259
+ requestPBObjectConstructor: identity_pb_1.RemoveUserFromWorkspaceRequest,
260
+ metadata: this.client.getMetadata(),
261
+ request: { userRef }
262
+ });
263
+ }
264
+ }
265
+ exports.Workspaces = Workspaces;
@@ -1,6 +1,11 @@
1
- import { ApplicationsClient, FonosterClient, IdentityClient } from "./types";
1
+ import { ApplicationsClient, CallsClient, FonosterClient, IdentityClient, SecretsClient } from "./types";
2
+ import { AclsClient } from "./types/AclsClient";
3
+ import { AgentsClient } from "./types/AgentsClient";
4
+ import { CredentialsClient } from "./types/CredentialsClient";
5
+ import { DomainsClient } from "./types/DomainsClient";
6
+ import { NumbersClient } from "./types/NumbersClient";
7
+ import { TrunksClient } from "./types/TrunksClient";
2
8
  declare abstract class AbstractClient implements FonosterClient {
3
- protected idToken: string;
4
9
  protected accessKeyId: string;
5
10
  protected _accessToken: string;
6
11
  protected _refreshToken: string;
@@ -18,5 +23,14 @@ declare abstract class AbstractClient implements FonosterClient {
18
23
  getRefreshToken(): string;
19
24
  abstract getMetadata(): unknown;
20
25
  abstract getApplicationsClient(): ApplicationsClient;
26
+ abstract getIdentityClient(): IdentityClient;
27
+ abstract getSecretsClient(): SecretsClient;
28
+ abstract getAgentsClient(): AgentsClient;
29
+ abstract getNumbersClient(): NumbersClient;
30
+ abstract getCredentialsClient(): CredentialsClient;
31
+ abstract getDomainsClient(): DomainsClient;
32
+ abstract getTrunksClient(): TrunksClient;
33
+ abstract getAclsClient(): AclsClient;
34
+ abstract getCallsClient(): CallsClient;
21
35
  }
22
36
  export { AbstractClient };
@@ -22,7 +22,6 @@ exports.AbstractClient = void 0;
22
22
  const makeRpcRequest_1 = require("./makeRpcRequest");
23
23
  const identity_pb_1 = require("../generated/node/identity_pb");
24
24
  class AbstractClient {
25
- idToken;
26
25
  accessKeyId;
27
26
  _accessToken;
28
27
  _refreshToken;
@@ -11,5 +11,13 @@ export declare class Client extends AbstractClient {
11
11
  });
12
12
  getMetadata(): Metadata;
13
13
  getApplicationsClient(): any;
14
+ getCallsClient(): any;
14
15
  getIdentityClient(): any;
16
+ getSecretsClient(): any;
17
+ getAgentsClient(): any;
18
+ getAclsClient(): any;
19
+ getDomainsClient(): any;
20
+ getTrunksClient(): any;
21
+ getNumbersClient(): any;
22
+ getCredentialsClient(): any;
15
23
  }