@fonoster/sdk 0.6.5 → 0.6.6

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 (61) hide show
  1. package/README.md +519 -454
  2. package/dist/node/Acls.d.ts +43 -44
  3. package/dist/node/Acls.js +62 -49
  4. package/dist/node/Agents.d.ts +44 -45
  5. package/dist/node/Agents.js +47 -46
  6. package/dist/node/ApiKeys.d.ts +29 -29
  7. package/dist/node/ApiKeys.js +29 -29
  8. package/dist/node/Applications.d.ts +39 -39
  9. package/dist/node/Applications.js +52 -40
  10. package/dist/node/Calls.d.ts +28 -29
  11. package/dist/node/Calls.js +32 -27
  12. package/dist/node/Credentials.d.ts +39 -39
  13. package/dist/node/Credentials.js +39 -39
  14. package/dist/node/Domains.d.ts +37 -37
  15. package/dist/node/Domains.js +37 -37
  16. package/dist/node/Numbers.d.ts +40 -40
  17. package/dist/node/Numbers.js +40 -40
  18. package/dist/node/Secrets.d.ts +37 -37
  19. package/dist/node/Secrets.js +37 -37
  20. package/dist/node/Trunks.d.ts +58 -52
  21. package/dist/node/Trunks.js +104 -70
  22. package/dist/node/Users.d.ts +34 -34
  23. package/dist/node/Users.js +34 -34
  24. package/dist/node/Workspaces.d.ts +55 -54
  25. package/dist/node/Workspaces.js +61 -54
  26. package/dist/node/client/jsonToObject.js +1 -1
  27. package/dist/node/client/makeRpcRequest.js +1 -1
  28. package/dist/node/client/objectToJson.d.ts +1 -1
  29. package/dist/node/client/objectToJson.js +12 -2
  30. package/dist/node/client/types/IdentityClient.d.ts +2 -2
  31. package/dist/node/client/utils.js +6 -3
  32. package/dist/node/generated/node/agents_grpc_pb.js +0 -2
  33. package/dist/node/generated/node/agents_pb.js +444 -24
  34. package/dist/node/generated/node/applications_pb.js +6 -6
  35. package/dist/node/generated/node/credentials_pb.js +11 -41
  36. package/dist/node/generated/node/domains_pb.js +30 -30
  37. package/dist/node/generated/node/identity_grpc_pb.js +14 -14
  38. package/dist/node/generated/node/identity_pb.js +37 -37
  39. package/dist/node/generated/node/numbers_grpc_pb.js +0 -1
  40. package/dist/node/generated/node/numbers_pb.js +191 -11
  41. package/dist/node/generated/node/trunks_grpc_pb.js +0 -2
  42. package/dist/node/generated/node/trunks_pb.js +526 -31
  43. package/dist/node/generated/web/IdentityServiceClientPb.ts +5 -5
  44. package/dist/node/generated/web/agents_pb.d.ts +62 -10
  45. package/dist/node/generated/web/agents_pb.js +444 -24
  46. package/dist/node/generated/web/applications_pb.js +6 -6
  47. package/dist/node/generated/web/credentials_pb.d.ts +0 -4
  48. package/dist/node/generated/web/credentials_pb.js +11 -41
  49. package/dist/node/generated/web/domains_pb.js +30 -30
  50. package/dist/node/generated/web/identity_pb.d.ts +13 -13
  51. package/dist/node/generated/web/identity_pb.js +37 -37
  52. package/dist/node/generated/web/numbers_pb.d.ts +26 -4
  53. package/dist/node/generated/web/numbers_pb.js +191 -11
  54. package/dist/node/generated/web/trunks_pb.d.ts +71 -11
  55. package/dist/node/generated/web/trunks_pb.js +526 -31
  56. package/dist/node/tsconfig.node.tsbuildinfo +1 -1
  57. package/dist/node/utils.d.ts +4 -3
  58. package/dist/node/utils.js +36 -0
  59. package/dist/web/fonoster.min.js +1 -1
  60. package/dist/web/index.esm.js +1 -1
  61. package/package.json +4 -4
@@ -10,11 +10,11 @@ import { FonosterClient } from "./client/types";
10
10
  * const SDK = require("@fonoster/sdk");
11
11
  *
12
12
  * async function main(request) {
13
- * const apiKey = "your-api-key";
14
- * const accessKeyId = "00000000-0000-0000-0000-000000000000";
13
+ * const API_KEY = "your-api-key";
14
+ * const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
15
15
  *
16
- * try {
17
- * const client = SDK.Client({ accessKeyId });
16
+ * try {
17
+ * const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
18
18
  * await client.loginWithApiKey(apiKey);
19
19
  *
20
20
  * const workspaces = new SDK.Workspaces(client);
@@ -49,16 +49,16 @@ declare class Workspaces {
49
49
  * @param {string} request.name - The name of the Workspace
50
50
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Workspace
51
51
  * @example
52
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
52
53
  *
53
54
  * const request = {
54
- * name: "My Workspace"
55
+ * name: "My Workspace"
55
56
  * };
56
57
  *
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
58
+ * workspaces
59
+ * .createWorkspace(request)
60
+ * .then(console.log) // successful response
61
+ * .catch(console.error); // an error occurred
62
62
  */
63
63
  createWorkspace(request: CreateWorkspaceRequest): Promise<BaseApiObject>;
64
64
  /**
@@ -67,14 +67,14 @@ declare class Workspaces {
67
67
  * @param {string} ref - The reference of the Workspace to retrieve
68
68
  * @return {Promise<Acl>} - The response object that contains the Workspace
69
69
  * @example
70
- *
71
- * const ref = "00000000-0000-0000-0000-000000000000"
72
- *
73
70
  * const workspaces = new SDK.Workspaces(client); // Existing client object
74
71
  *
75
- * workspaces.getWorkspace(ref)
76
- * .then(console.log) // successful response
77
- * .catch(console.error); // an error occurred
72
+ * const ref = "00000000-0000-0000-0000-000000000000";
73
+ *
74
+ * workspaces
75
+ * .getWorkspace(ref)
76
+ * .then(console.log) // successful response
77
+ * .catch(console.error); // an error occurred
78
78
  */
79
79
  getWorkspace(ref: string): Promise<Workspace>;
80
80
  /**
@@ -85,17 +85,17 @@ declare class Workspaces {
85
85
  * @param {string} request.name - The name of the Workspace
86
86
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Workspace
87
87
  * @example
88
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
88
89
  *
89
90
  * const request = {
90
- * ref: "00000000-0000-0000-0000-000000000000",
91
- * name: "My Workspace"
91
+ * ref: "00000000-0000-0000-0000-000000000000",
92
+ * name: "My Workspace"
92
93
  * };
93
94
  *
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
95
+ * workspaces
96
+ * .updateWorkspace(request)
97
+ * .then(console.log) // successful response
98
+ * .catch(console.error); // an error occurred
99
99
  */
100
100
  updateWorkspace(request: UpdateWorkspaceRequest): Promise<BaseApiObject>;
101
101
  /**
@@ -105,14 +105,14 @@ declare class Workspaces {
105
105
  * @param {string} ref - The reference of the Workspace to delete
106
106
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Workspace
107
107
  * @example
108
- *
109
- * const ref = "00000000-0000-0000-0000-000000000000"
110
- *
111
108
  * const workspaces = new SDK.Workspaces(client); // Existing client object
112
109
  *
113
- * workspaces.deleteWorkspace(ref)
114
- * .then(console.log) // successful response
115
- * .catch(console.error); // an error occurred
110
+ * const ref = "00000000-0000-0000-0000-000000000000";
111
+ *
112
+ * workspaces
113
+ * .deleteWorkspace(ref)
114
+ * .then(console.log) // successful response
115
+ * .catch(console.error); // an error occurred
116
116
  */
117
117
  deleteWorkspace(ref: string): Promise<BaseApiObject>;
118
118
  /**
@@ -123,17 +123,17 @@ declare class Workspaces {
123
123
  * @param {string} request.pageToken - The token to retrieve the next page of Workspaces
124
124
  * @return {Promise<ListWorkspacesResponse>} - The response object that contains the list of Workspaces
125
125
  * @example
126
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
126
127
  *
127
128
  * const request = {
128
- * pageSize: 10,
129
- * pageToken: "00000000-0000-0000-0000-000000000000"
129
+ * pageSize: 10,
130
+ * pageToken: "00000000-0000-0000-0000-000000000000"
130
131
  * };
131
132
  *
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
133
+ * workspaces
134
+ * .listWorkspaces(request)
135
+ * .then(console.log) // successful response
136
+ * .catch(console.error); // an error occurred
137
137
  */
138
138
  listWorkspaces(): Promise<ListWorkspacesResponse>;
139
139
  /**
@@ -145,18 +145,19 @@ declare class Workspaces {
145
145
  * @param {string} request.password - Temporary password for the User. Leave empty to generate a random password
146
146
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the invitation
147
147
  * @example
148
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
148
149
  *
149
150
  * const request = {
150
- * workspaceRef: "00000000-0000-0000-0000-000000000000",
151
- * email: "jane.doe@example.com",
152
- * role: "WORKSPACE_MEMBER",
151
+ * workspaceRef: "00000000-0000-0000-0000-000000000000",
152
+ * email: "jane.doe@example.com",
153
+ * role: "WORKSPACE_MEMBER",
154
+ * password: "password" // Temporary password for the User. Leave empty to generate a random password
153
155
  * };
154
156
  *
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
157
+ * workspaces
158
+ * .inviteUserToWorkspace(request)
159
+ * .then(console.log) // successful response
160
+ * .catch(console.error); // an error occurred
160
161
  */
161
162
  inviteUserToWorkspace(request: InviteUserToWorkspaceRequest): Promise<BaseApiObject>;
162
163
  /**
@@ -165,14 +166,14 @@ declare class Workspaces {
165
166
  * @param {string} userRef - The reference to the user to resend the invitation
166
167
  * @return {Promise<ResendWorkspaceMembershipInvitationResponse>} - The response object that contains the reference to the invitation
167
168
  * @example
169
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
168
170
  *
169
171
  * const userRef: "00000000-0000-0000-0000-000000000000";
170
172
  *
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
173
+ * workspaces
174
+ * .resendWorkspaceMembershipInvitation(request)
175
+ * .then(console.log) // successful response
176
+ * .catch(console.error); // an error occurred
176
177
  */
177
178
  resendWorkspaceMembershipInvitation(userRef: string): Promise<ResendWorkspaceMembershipInvitationResponse>;
178
179
  /**
@@ -181,14 +182,14 @@ declare class Workspaces {
181
182
  * @param {string} userRef - The reference of the User to remove from the Workspace
182
183
  * @return {Promise<RemoveUserFromWorkspaceResponse>} - The response object that contains the reference to the removed User
183
184
  * @example
185
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
184
186
  *
185
187
  * const userRef = "00000000-0000-0000-0000-000000000000";
186
188
  *
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
189
+ * workspaces
190
+ * .removeUserFromWorkspace(userRef)
191
+ * .then(console.log) // successful response
192
+ * .catch(console.error); // an error occurred
192
193
  */
193
194
  removeUserFromWorkspace(userRef: string): Promise<RemoveUserFromWorkspaceResponse>;
194
195
  }
@@ -13,11 +13,11 @@ const identity_pb_1 = require("./generated/node/identity_pb");
13
13
  * const SDK = require("@fonoster/sdk");
14
14
  *
15
15
  * async function main(request) {
16
- * const apiKey = "your-api-key";
17
- * const accessKeyId = "00000000-0000-0000-0000-000000000000";
16
+ * const API_KEY = "your-api-key";
17
+ * const ACCESS_KEY_ID = "00000000-0000-0000-0000-000000000000";
18
18
  *
19
- * try {
20
- * const client = SDK.Client({ accessKeyId });
19
+ * try {
20
+ * const client = SDK.Client({ accessKeyId: ACCESS_KEY_ID });
21
21
  * await client.loginWithApiKey(apiKey);
22
22
  *
23
23
  * const workspaces = new SDK.Workspaces(client);
@@ -54,16 +54,16 @@ class Workspaces {
54
54
  * @param {string} request.name - The name of the Workspace
55
55
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the created Workspace
56
56
  * @example
57
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
57
58
  *
58
59
  * const request = {
59
- * name: "My Workspace"
60
+ * name: "My Workspace"
60
61
  * };
61
62
  *
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
63
+ * workspaces
64
+ * .createWorkspace(request)
65
+ * .then(console.log) // successful response
66
+ * .catch(console.error); // an error occurred
67
67
  */
68
68
  async createWorkspace(request) {
69
69
  const client = this.client.getIdentityClient();
@@ -80,14 +80,14 @@ class Workspaces {
80
80
  * @param {string} ref - The reference of the Workspace to retrieve
81
81
  * @return {Promise<Acl>} - The response object that contains the Workspace
82
82
  * @example
83
- *
84
- * const ref = "00000000-0000-0000-0000-000000000000"
85
- *
86
83
  * const workspaces = new SDK.Workspaces(client); // Existing client object
87
84
  *
88
- * workspaces.getWorkspace(ref)
89
- * .then(console.log) // successful response
90
- * .catch(console.error); // an error occurred
85
+ * const ref = "00000000-0000-0000-0000-000000000000";
86
+ *
87
+ * workspaces
88
+ * .getWorkspace(ref)
89
+ * .then(console.log) // successful response
90
+ * .catch(console.error); // an error occurred
91
91
  */
92
92
  async getWorkspace(ref) {
93
93
  const client = this.client.getIdentityClient();
@@ -106,17 +106,17 @@ class Workspaces {
106
106
  * @param {string} request.name - The name of the Workspace
107
107
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the updated Workspace
108
108
  * @example
109
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
109
110
  *
110
111
  * const request = {
111
- * ref: "00000000-0000-0000-0000-000000000000",
112
- * name: "My Workspace"
112
+ * ref: "00000000-0000-0000-0000-000000000000",
113
+ * name: "My Workspace"
113
114
  * };
114
115
  *
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
116
+ * workspaces
117
+ * .updateWorkspace(request)
118
+ * .then(console.log) // successful response
119
+ * .catch(console.error); // an error occurred
120
120
  */
121
121
  async updateWorkspace(request) {
122
122
  const client = this.client.getIdentityClient();
@@ -134,14 +134,14 @@ class Workspaces {
134
134
  * @param {string} ref - The reference of the Workspace to delete
135
135
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the deleted Workspace
136
136
  * @example
137
- *
138
- * const ref = "00000000-0000-0000-0000-000000000000"
139
- *
140
137
  * const workspaces = new SDK.Workspaces(client); // Existing client object
141
138
  *
142
- * workspaces.deleteWorkspace(ref)
143
- * .then(console.log) // successful response
144
- * .catch(console.error); // an error occurred
139
+ * const ref = "00000000-0000-0000-0000-000000000000";
140
+ *
141
+ * workspaces
142
+ * .deleteWorkspace(ref)
143
+ * .then(console.log) // successful response
144
+ * .catch(console.error); // an error occurred
145
145
  */
146
146
  async deleteWorkspace(ref) {
147
147
  const client = this.client.getIdentityClient();
@@ -160,17 +160,17 @@ class Workspaces {
160
160
  * @param {string} request.pageToken - The token to retrieve the next page of Workspaces
161
161
  * @return {Promise<ListWorkspacesResponse>} - The response object that contains the list of Workspaces
162
162
  * @example
163
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
163
164
  *
164
165
  * const request = {
165
- * pageSize: 10,
166
- * pageToken: "00000000-0000-0000-0000-000000000000"
166
+ * pageSize: 10,
167
+ * pageToken: "00000000-0000-0000-0000-000000000000"
167
168
  * };
168
169
  *
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
170
+ * workspaces
171
+ * .listWorkspaces(request)
172
+ * .then(console.log) // successful response
173
+ * .catch(console.error); // an error occurred
174
174
  */
175
175
  async listWorkspaces() {
176
176
  const applicationsClient = this.client.getIdentityClient();
@@ -191,20 +191,23 @@ class Workspaces {
191
191
  * @param {string} request.password - Temporary password for the User. Leave empty to generate a random password
192
192
  * @return {Promise<BaseApiObject>} - The response object that contains the reference to the invitation
193
193
  * @example
194
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
194
195
  *
195
196
  * const request = {
196
- * workspaceRef: "00000000-0000-0000-0000-000000000000",
197
- * email: "jane.doe@example.com",
198
- * role: "WORKSPACE_MEMBER",
197
+ * workspaceRef: "00000000-0000-0000-0000-000000000000",
198
+ * email: "jane.doe@example.com",
199
+ * role: "WORKSPACE_MEMBER",
200
+ * password: "password" // Temporary password for the User. Leave empty to generate a random password
199
201
  * };
200
202
  *
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
203
+ * workspaces
204
+ * .inviteUserToWorkspace(request)
205
+ * .then(console.log) // successful response
206
+ * .catch(console.error); // an error occurred
206
207
  */
207
208
  async inviteUserToWorkspace(request) {
209
+ // TODO: We should allow passing the workspaceRef as an argument
210
+ // instead of using the Metadata
208
211
  const client = this.client.getIdentityClient();
209
212
  return await (0, makeRpcRequest_1.makeRpcRequest)({
210
213
  method: client.inviteUserToWorkspace.bind(client),
@@ -219,16 +222,18 @@ class Workspaces {
219
222
  * @param {string} userRef - The reference to the user to resend the invitation
220
223
  * @return {Promise<ResendWorkspaceMembershipInvitationResponse>} - The response object that contains the reference to the invitation
221
224
  * @example
225
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
222
226
  *
223
227
  * const userRef: "00000000-0000-0000-0000-000000000000";
224
228
  *
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
229
+ * workspaces
230
+ * .resendWorkspaceMembershipInvitation(request)
231
+ * .then(console.log) // successful response
232
+ * .catch(console.error); // an error occurred
230
233
  */
231
234
  async resendWorkspaceMembershipInvitation(userRef) {
235
+ // TODO: We should allow passing the workspaceRef as an argument
236
+ // instead of using the Metadata
232
237
  const client = this.client.getIdentityClient();
233
238
  return await (0, makeRpcRequest_1.makeRpcRequest)({
234
239
  method: client.resendWorkspaceMembershipInvitation.bind(client),
@@ -243,16 +248,18 @@ class Workspaces {
243
248
  * @param {string} userRef - The reference of the User to remove from the Workspace
244
249
  * @return {Promise<RemoveUserFromWorkspaceResponse>} - The response object that contains the reference to the removed User
245
250
  * @example
251
+ * const workspaces = new SDK.Workspaces(client); // Existing client object
246
252
  *
247
253
  * const userRef = "00000000-0000-0000-0000-000000000000";
248
254
  *
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
255
+ * workspaces
256
+ * .removeUserFromWorkspace(userRef)
257
+ * .then(console.log) // successful response
258
+ * .catch(console.error); // an error occurred
254
259
  */
255
260
  async removeUserFromWorkspace(userRef) {
261
+ // TODO: We should allow passing the workspaceRef as an argument
262
+ // instead of using the Metadata
256
263
  const client = this.client.getIdentityClient();
257
264
  return await (0, makeRpcRequest_1.makeRpcRequest)({
258
265
  method: client.removeUserFromWorkspace.bind(client),
@@ -7,7 +7,7 @@ function jsonToObject(params) {
7
7
  const instance = new ObjectConstructor();
8
8
  Object.keys(json).forEach((key) => {
9
9
  const setterName = `set${key.charAt(0).toUpperCase() + key.slice(1)}`;
10
- if (!json[key]) {
10
+ if (json[key] === null || json[key] === undefined) {
11
11
  return;
12
12
  }
13
13
  if ((0, utils_1.isMapping)(key, enumMapping)) {
@@ -37,7 +37,7 @@ function makeRpcRequest(params) {
37
37
  reject(err);
38
38
  return;
39
39
  }
40
- const json = (0, objectToJson_1.objectToJson)(responsePB, null, repeatableObjectMapping);
40
+ const json = (0, objectToJson_1.objectToJson)(responsePB, enumMapping, objectMapping, repeatableObjectMapping);
41
41
  resolve(json);
42
42
  });
43
43
  });
@@ -1,3 +1,3 @@
1
1
  import { MappingTuple } from "./types";
2
- declare function objectToJson<J extends Record<string, unknown>>(obj: new () => unknown, enumMapping?: MappingTuple<unknown>, repeatableObjectMapping?: MappingTuple<unknown>): J;
2
+ declare function objectToJson<J extends Record<string, unknown>>(obj: new () => unknown, enumMapping?: MappingTuple<unknown>, objectMapping?: MappingTuple<unknown>, repeatableObjectMapping?: MappingTuple<unknown>): J;
3
3
  export { objectToJson };
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.objectToJson = objectToJson;
4
4
  const utils_1 = require("./utils");
5
- function objectToJson(obj, enumMapping, repeatableObjectMapping) {
5
+ function objectToJson(obj, enumMapping, objectMapping, repeatableObjectMapping) {
6
6
  const json = {};
7
7
  Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).forEach((key) => {
8
8
  if (key.startsWith("get") &&
@@ -11,15 +11,25 @@ function objectToJson(obj, enumMapping, repeatableObjectMapping) {
11
11
  const propName = key.charAt(3).toLowerCase() + key.slice(4);
12
12
  try {
13
13
  const value = obj[key]();
14
+ if (value === null || value === undefined || value === "") {
15
+ return;
16
+ }
14
17
  if ((0, utils_1.isMapping)(propName, enumMapping)) {
15
18
  json[propName] = (0, utils_1.getEnumKey)(propName, value, enumMapping);
16
19
  }
20
+ else if ((0, utils_1.isMapping)(propName, objectMapping)) {
21
+ json[propName] = objectToJson(value, enumMapping, objectMapping, repeatableObjectMapping);
22
+ }
17
23
  else if ((0, utils_1.isMapping)(propName, repeatableObjectMapping)) {
18
24
  // Remove the "List" ending from the key
19
25
  const repeatableKey = propName.slice(0, -4);
20
- json[repeatableKey] = value.map((item) => objectToJson(item));
26
+ json[repeatableKey] = value.map((item) => objectToJson(item, enumMapping, objectMapping, repeatableObjectMapping));
21
27
  }
22
28
  else if (value !== undefined) {
29
+ if (["createdAt", "updatedAt", "startedAt", "endedAt"].includes(propName)) {
30
+ json[propName] = new Date(value * 1000);
31
+ return;
32
+ }
23
33
  json[propName] = value;
24
34
  }
25
35
  }
@@ -1,4 +1,4 @@
1
- import { CreateApiKeyRequest, CreateApiKeyResponse, CreateUserRequest, CreateUserResponse, CreateWorkspaceRequest, DeleteApiKeyRequest, DeleteApiKeyResponse, DeleteUserRequest, DeleteUserResponse, DeleteWorkspaceRequest, DeleteWorkspaceResponse, ExchangeApiKeyRequest, ExchangeApiKeyResponse, ExchangeCredentialsRequest, ExchangeCredentialsResponse, ExchangeRefreshTokenRequest, ExchangeRefreshTokenResponse, GetUserRequest, GetUserResponse, GetWorkspaceRequest, InviteUserToWorkspaceRequest, InviteUserToWorkspaceResponse, ListApiKeysRequest, ListApiKeysResponse, ListWorkspacesRequest, ListWorkspacesResponse, RegenerateApiKeyRequest, RegenerateApiKeyResponse, RemoveUserFromWorkspaceRequest, RemoveUserFromWorkspaceResponse, ResendWorkspaceMembershipInvitationRequest, ResendWorkspaceMembershipInvitationResponse, UpdateUserRequest, UpdateWorkspaceRequest, UpdateWorkspaceResponse, Workspace } from "../../generated/web/identity_pb";
1
+ import { CreateApiKeyRequest, CreateApiKeyResponse, CreateUserRequest, CreateUserResponse, CreateWorkspaceRequest, DeleteApiKeyRequest, DeleteApiKeyResponse, DeleteUserRequest, DeleteUserResponse, DeleteWorkspaceRequest, DeleteWorkspaceResponse, ExchangeApiKeyRequest, ExchangeApiKeyResponse, ExchangeCredentialsRequest, ExchangeCredentialsResponse, ExchangeRefreshTokenRequest, ExchangeRefreshTokenResponse, GetUserRequest, GetWorkspaceRequest, InviteUserToWorkspaceRequest, InviteUserToWorkspaceResponse, ListApiKeysRequest, ListApiKeysResponse, ListWorkspacesRequest, ListWorkspacesResponse, RegenerateApiKeyRequest, RegenerateApiKeyResponse, RemoveUserFromWorkspaceRequest, RemoveUserFromWorkspaceResponse, ResendWorkspaceMembershipInvitationRequest, ResendWorkspaceMembershipInvitationResponse, UpdateUserRequest, UpdateWorkspaceRequest, UpdateWorkspaceResponse, User, Workspace } from "../../generated/web/identity_pb";
2
2
  import { ClientFunction } from "../types";
3
3
  type IdentityClient = {
4
4
  createApiKey: ClientFunction<CreateApiKeyRequest, CreateApiKeyResponse>;
@@ -9,7 +9,7 @@ type IdentityClient = {
9
9
  exchangeCredentials: ClientFunction<ExchangeCredentialsRequest, ExchangeCredentialsResponse>;
10
10
  exchangeRefreshToken: ClientFunction<ExchangeRefreshTokenRequest, ExchangeRefreshTokenResponse>;
11
11
  createUser: ClientFunction<CreateUserRequest, CreateUserResponse>;
12
- getUser: ClientFunction<GetUserRequest, GetUserResponse>;
12
+ getUser: ClientFunction<GetUserRequest, User>;
13
13
  updateUser: ClientFunction<UpdateUserRequest, CreateUserResponse>;
14
14
  deleteUser: ClientFunction<DeleteUserRequest, DeleteUserResponse>;
15
15
  createWorkspace: ClientFunction<CreateWorkspaceRequest, CreateUserResponse>;
@@ -7,11 +7,14 @@ function isMapping(key, objectMapping) {
7
7
  return objectMapping?.some((tuple) => tuple[0] === key);
8
8
  }
9
9
  function getEnumValue(key, value, enumMapping) {
10
+ // Added to support the edge case of "PRIVATE" being passed as "ID"
11
+ const realValue = value === "ID" ? "PRIVATE" : value;
10
12
  const tuple = enumMapping.find((tuple) => tuple[0] === key);
11
- return (tuple ? tuple[1][value] : 0);
13
+ return (tuple ? tuple[1][realValue] : 0);
12
14
  }
13
15
  function getEnumKey(key, value, enumMapping) {
14
16
  const tuple = enumMapping.find((tuple) => tuple[0] === key);
15
- // Take the value of the tuple and find the key
16
- return Object.keys(tuple[1]).find((k) => tuple[1][k] === value) || "";
17
+ const result = Object.keys(tuple[1]).find((k) => tuple[1][k] === value) || "";
18
+ // Added to support the edge case of "PRIVATE" being returned as "ID"
19
+ return result === "PRIVATE" ? "ID" : result;
17
20
  }
@@ -21,8 +21,6 @@
21
21
  'use strict';
22
22
  var grpc = require('@grpc/grpc-js');
23
23
  var agents_pb = require('./agents_pb.js');
24
- var domains_pb = require('./domains_pb.js');
25
- var credentials_pb = require('./credentials_pb.js');
26
24
 
27
25
  function serialize_fonoster_agents_v1beta2_Agent(arg) {
28
26
  if (!(arg instanceof agents_pb.Agent)) {