@lifestreamdynamics/vault-sdk 1.0.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.
- package/LICENSE +21 -0
- package/README.md +1121 -0
- package/dist/client.d.ts +143 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +286 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +28 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +49 -0
- package/dist/errors.js.map +1 -0
- package/dist/handle-error.d.ts +8 -0
- package/dist/handle-error.d.ts.map +1 -0
- package/dist/handle-error.js +35 -0
- package/dist/handle-error.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audit-logger.d.ts +29 -0
- package/dist/lib/audit-logger.d.ts.map +1 -0
- package/dist/lib/audit-logger.js +99 -0
- package/dist/lib/audit-logger.js.map +1 -0
- package/dist/lib/encryption.d.ts +34 -0
- package/dist/lib/encryption.d.ts.map +1 -0
- package/dist/lib/encryption.js +87 -0
- package/dist/lib/encryption.js.map +1 -0
- package/dist/lib/signature.d.ts +47 -0
- package/dist/lib/signature.d.ts.map +1 -0
- package/dist/lib/signature.js +71 -0
- package/dist/lib/signature.js.map +1 -0
- package/dist/lib/token-manager.d.ts +80 -0
- package/dist/lib/token-manager.d.ts.map +1 -0
- package/dist/lib/token-manager.js +116 -0
- package/dist/lib/token-manager.js.map +1 -0
- package/dist/resources/admin.d.ts +280 -0
- package/dist/resources/admin.d.ts.map +1 -0
- package/dist/resources/admin.js +236 -0
- package/dist/resources/admin.js.map +1 -0
- package/dist/resources/ai.d.ts +184 -0
- package/dist/resources/ai.d.ts.map +1 -0
- package/dist/resources/ai.js +179 -0
- package/dist/resources/ai.js.map +1 -0
- package/dist/resources/api-keys.d.ts +172 -0
- package/dist/resources/api-keys.d.ts.map +1 -0
- package/dist/resources/api-keys.js +166 -0
- package/dist/resources/api-keys.js.map +1 -0
- package/dist/resources/connectors.d.ts +263 -0
- package/dist/resources/connectors.d.ts.map +1 -0
- package/dist/resources/connectors.js +226 -0
- package/dist/resources/connectors.js.map +1 -0
- package/dist/resources/documents.d.ts +334 -0
- package/dist/resources/documents.d.ts.map +1 -0
- package/dist/resources/documents.js +377 -0
- package/dist/resources/documents.js.map +1 -0
- package/dist/resources/hooks.d.ts +195 -0
- package/dist/resources/hooks.d.ts.map +1 -0
- package/dist/resources/hooks.js +166 -0
- package/dist/resources/hooks.js.map +1 -0
- package/dist/resources/publish.d.ts +165 -0
- package/dist/resources/publish.d.ts.map +1 -0
- package/dist/resources/publish.js +150 -0
- package/dist/resources/publish.js.map +1 -0
- package/dist/resources/search.d.ts +94 -0
- package/dist/resources/search.d.ts.map +1 -0
- package/dist/resources/search.js +76 -0
- package/dist/resources/search.js.map +1 -0
- package/dist/resources/shares.d.ts +130 -0
- package/dist/resources/shares.d.ts.map +1 -0
- package/dist/resources/shares.js +115 -0
- package/dist/resources/shares.js.map +1 -0
- package/dist/resources/subscription.d.ts +172 -0
- package/dist/resources/subscription.d.ts.map +1 -0
- package/dist/resources/subscription.js +166 -0
- package/dist/resources/subscription.js.map +1 -0
- package/dist/resources/teams.d.ts +356 -0
- package/dist/resources/teams.d.ts.map +1 -0
- package/dist/resources/teams.js +395 -0
- package/dist/resources/teams.js.map +1 -0
- package/dist/resources/user.d.ts +92 -0
- package/dist/resources/user.d.ts.map +1 -0
- package/dist/resources/user.js +64 -0
- package/dist/resources/user.js.map +1 -0
- package/dist/resources/vaults.d.ts +144 -0
- package/dist/resources/vaults.d.ts.map +1 -0
- package/dist/resources/vaults.js +158 -0
- package/dist/resources/vaults.js.map +1 -0
- package/dist/resources/webhooks.d.ts +187 -0
- package/dist/resources/webhooks.d.ts.map +1 -0
- package/dist/resources/webhooks.js +171 -0
- package/dist/resources/webhooks.js.map +1 -0
- package/dist/types/api.d.ts +17 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +2 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/resources.d.ts +5 -0
- package/dist/types/resources.d.ts.map +1 -0
- package/dist/types/resources.js +2 -0
- package/dist/types/resources.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { handleError } from '../handle-error.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resource for managing teams, members, invitations, and team vaults.
|
|
4
|
+
*
|
|
5
|
+
* Teams allow users to collaborate on shared vaults with role-based access
|
|
6
|
+
* control. Team members can be owners, admins, or regular members.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const teams = await client.teams.list();
|
|
11
|
+
* const team = await client.teams.create({ name: 'Engineering' });
|
|
12
|
+
* const members = await client.teams.listMembers(team.id);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class TeamsResource {
|
|
16
|
+
http;
|
|
17
|
+
constructor(http) {
|
|
18
|
+
this.http = http;
|
|
19
|
+
}
|
|
20
|
+
// ── Team CRUD ──────────────────────────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* Lists all teams the authenticated user belongs to.
|
|
23
|
+
*
|
|
24
|
+
* @returns Array of team objects
|
|
25
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
26
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const teams = await client.teams.list();
|
|
31
|
+
* for (const team of teams) {
|
|
32
|
+
* console.log(team.name);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
async list() {
|
|
37
|
+
try {
|
|
38
|
+
const data = await this.http.get('teams').json();
|
|
39
|
+
return data.teams;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw await handleError(error, 'Teams', '');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves a single team by ID.
|
|
47
|
+
*
|
|
48
|
+
* @param teamId - The unique identifier of the team
|
|
49
|
+
* @returns The team object
|
|
50
|
+
* @throws {NotFoundError} If no team exists with the given ID
|
|
51
|
+
* @throws {AuthorizationError} If the user is not a member of the team
|
|
52
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
53
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const team = await client.teams.get('team-uuid');
|
|
58
|
+
* console.log(team.name, team.description);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
async get(teamId) {
|
|
62
|
+
try {
|
|
63
|
+
return await this.http.get(`teams/${teamId}`).json();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
throw await handleError(error, 'Team', teamId);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new team. The authenticated user becomes the team owner.
|
|
71
|
+
*
|
|
72
|
+
* @param params - Team creation parameters
|
|
73
|
+
* @param params.name - Display name for the team (required)
|
|
74
|
+
* @param params.description - Optional description of the team's purpose
|
|
75
|
+
* @returns The newly created team object
|
|
76
|
+
* @throws {ValidationError} If the name is empty or invalid
|
|
77
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
78
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const team = await client.teams.create({
|
|
83
|
+
* name: 'Engineering',
|
|
84
|
+
* description: 'Backend and frontend engineering team',
|
|
85
|
+
* });
|
|
86
|
+
* console.log(team.id);
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
async create(params) {
|
|
90
|
+
try {
|
|
91
|
+
return await this.http.post('teams', { json: params }).json();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
throw await handleError(error, 'Team', params.name);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Updates an existing team's metadata. Requires admin or owner role.
|
|
99
|
+
*
|
|
100
|
+
* Only the provided fields are modified; omitted fields remain unchanged.
|
|
101
|
+
*
|
|
102
|
+
* @param teamId - The unique identifier of the team to update
|
|
103
|
+
* @param params - Fields to update
|
|
104
|
+
* @param params.name - New display name for the team
|
|
105
|
+
* @param params.description - New description, or `null` to clear
|
|
106
|
+
* @returns The updated team object
|
|
107
|
+
* @throws {NotFoundError} If no team exists with the given ID
|
|
108
|
+
* @throws {AuthorizationError} If the user lacks admin/owner role
|
|
109
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
110
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const updated = await client.teams.update('team-uuid', {
|
|
115
|
+
* name: 'Platform Engineering',
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
async update(teamId, params) {
|
|
120
|
+
try {
|
|
121
|
+
return await this.http.patch(`teams/${teamId}`, { json: params }).json();
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
throw await handleError(error, 'Team', teamId);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Permanently deletes a team. Only the team owner can delete a team.
|
|
129
|
+
*
|
|
130
|
+
* This removes all memberships, invitations, and team vault associations.
|
|
131
|
+
*
|
|
132
|
+
* @param teamId - The unique identifier of the team to delete
|
|
133
|
+
* @throws {NotFoundError} If no team exists with the given ID
|
|
134
|
+
* @throws {AuthorizationError} If the user is not the team owner
|
|
135
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
136
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* await client.teams.delete('team-uuid');
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
async delete(teamId) {
|
|
144
|
+
try {
|
|
145
|
+
await this.http.delete(`teams/${teamId}`);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw await handleError(error, 'Team', teamId);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// ── Members ────────────────────────────────────────────────────────
|
|
152
|
+
/**
|
|
153
|
+
* Lists all members of a team.
|
|
154
|
+
*
|
|
155
|
+
* @param teamId - The unique identifier of the team
|
|
156
|
+
* @returns Array of team member objects with user details
|
|
157
|
+
* @throws {NotFoundError} If no team exists with the given ID
|
|
158
|
+
* @throws {AuthorizationError} If the user is not a member of the team
|
|
159
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
160
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const members = await client.teams.listMembers('team-uuid');
|
|
165
|
+
* for (const member of members) {
|
|
166
|
+
* console.log(member.user.email, member.role);
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
async listMembers(teamId) {
|
|
171
|
+
try {
|
|
172
|
+
const data = await this.http.get(`teams/${teamId}/members`).json();
|
|
173
|
+
return data.members;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
throw await handleError(error, 'Team', teamId);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Updates a team member's role. Requires admin or owner role.
|
|
181
|
+
*
|
|
182
|
+
* Cannot change the owner's role. Admins cannot promote others to owner.
|
|
183
|
+
*
|
|
184
|
+
* @param teamId - The unique identifier of the team
|
|
185
|
+
* @param userId - The user ID of the member to update
|
|
186
|
+
* @param role - The new role to assign (`'admin'` or `'member'`)
|
|
187
|
+
* @returns The updated team member object
|
|
188
|
+
* @throws {NotFoundError} If the team or member is not found
|
|
189
|
+
* @throws {AuthorizationError} If the user lacks permission to change roles
|
|
190
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
191
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const member = await client.teams.updateMemberRole('team-uuid', 'user-uuid', 'admin');
|
|
196
|
+
* console.log(member.role); // 'admin'
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
async updateMemberRole(teamId, userId, role) {
|
|
200
|
+
try {
|
|
201
|
+
return await this.http.patch(`teams/${teamId}/members/${userId}`, { json: { role } }).json();
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw await handleError(error, 'Team member', userId);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Removes a member from a team. Requires admin or owner role.
|
|
209
|
+
*
|
|
210
|
+
* The team owner cannot be removed.
|
|
211
|
+
*
|
|
212
|
+
* @param teamId - The unique identifier of the team
|
|
213
|
+
* @param userId - The user ID of the member to remove
|
|
214
|
+
* @throws {NotFoundError} If the team or member is not found
|
|
215
|
+
* @throws {AuthorizationError} If the user lacks permission or is trying to remove the owner
|
|
216
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
217
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* await client.teams.removeMember('team-uuid', 'user-uuid');
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
async removeMember(teamId, userId) {
|
|
225
|
+
try {
|
|
226
|
+
await this.http.delete(`teams/${teamId}/members/${userId}`);
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
throw await handleError(error, 'Team member', userId);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Leaves a team. The authenticated user removes themselves from the team.
|
|
234
|
+
*
|
|
235
|
+
* The team owner cannot leave; they must delete the team or transfer ownership first.
|
|
236
|
+
*
|
|
237
|
+
* @param teamId - The unique identifier of the team to leave
|
|
238
|
+
* @throws {NotFoundError} If no team exists with the given ID
|
|
239
|
+
* @throws {AuthorizationError} If the user is the team owner
|
|
240
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
241
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* await client.teams.leave('team-uuid');
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
async leave(teamId) {
|
|
249
|
+
try {
|
|
250
|
+
await this.http.post(`teams/${teamId}/members/leave`);
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
throw await handleError(error, 'Team', teamId);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// ── Invitations ────────────────────────────────────────────────────
|
|
257
|
+
/**
|
|
258
|
+
* Invites a user to join a team by email. Requires admin or owner role.
|
|
259
|
+
*
|
|
260
|
+
* @param teamId - The unique identifier of the team
|
|
261
|
+
* @param email - Email address of the user to invite
|
|
262
|
+
* @param role - Role to assign upon acceptance (`'admin'` or `'member'`)
|
|
263
|
+
* @returns The created invitation object
|
|
264
|
+
* @throws {ValidationError} If the email is invalid or the user is already a member
|
|
265
|
+
* @throws {AuthorizationError} If the user lacks admin/owner role
|
|
266
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
267
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const invitation = await client.teams.inviteMember(
|
|
272
|
+
* 'team-uuid',
|
|
273
|
+
* 'colleague@example.com',
|
|
274
|
+
* 'member',
|
|
275
|
+
* );
|
|
276
|
+
* console.log(invitation.expiresAt);
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
async inviteMember(teamId, email, role) {
|
|
280
|
+
try {
|
|
281
|
+
return await this.http.post(`teams/${teamId}/invitations`, { json: { email, role } }).json();
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
throw await handleError(error, 'Team invitation', email);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Lists all pending invitations for a team.
|
|
289
|
+
*
|
|
290
|
+
* @param teamId - The unique identifier of the team
|
|
291
|
+
* @returns Array of pending invitation objects
|
|
292
|
+
* @throws {NotFoundError} If no team exists with the given ID
|
|
293
|
+
* @throws {AuthorizationError} If the user is not a member of the team
|
|
294
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
295
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* const invitations = await client.teams.listInvitations('team-uuid');
|
|
300
|
+
* for (const inv of invitations) {
|
|
301
|
+
* console.log(inv.email, inv.role, inv.expiresAt);
|
|
302
|
+
* }
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
async listInvitations(teamId) {
|
|
306
|
+
try {
|
|
307
|
+
const data = await this.http.get(`teams/${teamId}/invitations`).json();
|
|
308
|
+
return data.invitations;
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
throw await handleError(error, 'Team', teamId);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Revokes a pending invitation. Requires admin or owner role.
|
|
316
|
+
*
|
|
317
|
+
* @param teamId - The unique identifier of the team
|
|
318
|
+
* @param invitationId - The unique identifier of the invitation to revoke
|
|
319
|
+
* @throws {NotFoundError} If the team or invitation is not found
|
|
320
|
+
* @throws {AuthorizationError} If the user lacks admin/owner role
|
|
321
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
322
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* await client.teams.revokeInvitation('team-uuid', 'invitation-uuid');
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
async revokeInvitation(teamId, invitationId) {
|
|
330
|
+
try {
|
|
331
|
+
await this.http.delete(`teams/${teamId}/invitations/${invitationId}`);
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
throw await handleError(error, 'Team invitation', invitationId);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
// ── Team Vaults ────────────────────────────────────────────────────
|
|
338
|
+
/**
|
|
339
|
+
* Creates a new vault under a team. Requires editor role or above.
|
|
340
|
+
*
|
|
341
|
+
* @param teamId - The unique identifier of the team
|
|
342
|
+
* @param params - Vault creation parameters
|
|
343
|
+
* @param params.name - Display name for the vault (required)
|
|
344
|
+
* @param params.description - Optional description of the vault's purpose
|
|
345
|
+
* @returns The newly created vault object
|
|
346
|
+
* @throws {ValidationError} If the name is empty or the slug conflicts
|
|
347
|
+
* @throws {AuthorizationError} If the user lacks the required team role
|
|
348
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
349
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```typescript
|
|
353
|
+
* const vault = await client.teams.createVault('team-uuid', {
|
|
354
|
+
* name: 'Shared Docs',
|
|
355
|
+
* description: 'Team documentation',
|
|
356
|
+
* });
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
async createVault(teamId, params) {
|
|
360
|
+
try {
|
|
361
|
+
return await this.http.post(`teams/${teamId}/vaults`, { json: params }).json();
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
throw await handleError(error, 'Team vault', params.name);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Lists all vaults belonging to a team.
|
|
369
|
+
*
|
|
370
|
+
* @param teamId - The unique identifier of the team
|
|
371
|
+
* @returns Array of vault objects
|
|
372
|
+
* @throws {NotFoundError} If no team exists with the given ID
|
|
373
|
+
* @throws {AuthorizationError} If the user is not a member of the team
|
|
374
|
+
* @throws {AuthenticationError} If the request is not authenticated
|
|
375
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```typescript
|
|
379
|
+
* const vaults = await client.teams.listVaults('team-uuid');
|
|
380
|
+
* for (const vault of vaults) {
|
|
381
|
+
* console.log(vault.name);
|
|
382
|
+
* }
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
async listVaults(teamId) {
|
|
386
|
+
try {
|
|
387
|
+
const data = await this.http.get(`teams/${teamId}/vaults`).json();
|
|
388
|
+
return data.vaults;
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
throw await handleError(error, 'Team', teamId);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../src/resources/teams.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAyEjD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC,sEAAsE;IAEtE;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAqB,CAAC;YACpE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAA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AgB,CAAC,MAAc,EAAE,YAAoB;QACzD,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,MAAM,gBAAgB,YAAY,EAAE,CAAC,CAAC;QACxE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,sEAAsE;IAEtE;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,MAA8C;QAC9E,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,MAAM,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAS,CAAC;QACxF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,CAAC,CAAC,IAAI,EAAuB,CAAC;YACvF,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { KyInstance } from 'ky';
|
|
2
|
+
/** The authenticated user's profile. */
|
|
3
|
+
export interface User {
|
|
4
|
+
/** Unique user identifier. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** User email address. */
|
|
7
|
+
email: string;
|
|
8
|
+
/** Display name, if set. */
|
|
9
|
+
name: string | null;
|
|
10
|
+
/** User role (`user` or `admin`). */
|
|
11
|
+
role: string;
|
|
12
|
+
/** Current subscription tier (`free`, `pro`, or `business`). */
|
|
13
|
+
subscriptionTier: string;
|
|
14
|
+
/** ISO 8601 subscription expiry timestamp, or `null` for free tier. */
|
|
15
|
+
subscriptionExpiresAt: string | null;
|
|
16
|
+
/** ISO 8601 account creation timestamp. */
|
|
17
|
+
createdAt: string;
|
|
18
|
+
/** ISO 8601 last-updated timestamp. */
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
}
|
|
21
|
+
/** Per-vault storage breakdown entry. */
|
|
22
|
+
export interface VaultStorage {
|
|
23
|
+
/** Vault identifier. */
|
|
24
|
+
vaultId: string;
|
|
25
|
+
/** Vault display name. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Total bytes used by documents in this vault. */
|
|
28
|
+
bytes: number;
|
|
29
|
+
/** Number of documents in this vault. */
|
|
30
|
+
documentCount: number;
|
|
31
|
+
}
|
|
32
|
+
/** Storage usage statistics for the authenticated user. */
|
|
33
|
+
export interface StorageUsage {
|
|
34
|
+
/** Total bytes used across all vaults. */
|
|
35
|
+
totalBytes: number;
|
|
36
|
+
/** Maximum bytes allowed by the user's plan. */
|
|
37
|
+
limitBytes: number;
|
|
38
|
+
/** Per-vault storage breakdown. */
|
|
39
|
+
vaults: VaultStorage[];
|
|
40
|
+
/** Total number of vaults. */
|
|
41
|
+
vaultCount: number;
|
|
42
|
+
/** Maximum number of vaults allowed by the user's plan. */
|
|
43
|
+
vaultLimit: number;
|
|
44
|
+
/** Current subscription tier. */
|
|
45
|
+
tier: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resource for retrieving user profile and storage information.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const user = await client.user.me();
|
|
53
|
+
* console.log(user.email, user.subscriptionTier);
|
|
54
|
+
*
|
|
55
|
+
* const storage = await client.user.getStorage();
|
|
56
|
+
* console.log(`${storage.totalBytes}/${storage.limitBytes} bytes used`);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare class UserResource {
|
|
60
|
+
private http;
|
|
61
|
+
constructor(http: KyInstance);
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves the current authenticated user's profile.
|
|
64
|
+
*
|
|
65
|
+
* @returns User profile object
|
|
66
|
+
* @throws {AuthenticationError} If not authenticated
|
|
67
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const user = await client.user.me();
|
|
72
|
+
* console.log(user.email, user.subscriptionTier);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
me(): Promise<User>;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves storage usage breakdown for the current user.
|
|
78
|
+
*
|
|
79
|
+
* @returns Storage usage statistics including per-vault breakdown
|
|
80
|
+
* @throws {AuthenticationError} If not authenticated
|
|
81
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const storage = await client.user.getStorage();
|
|
86
|
+
* console.log(`Using ${storage.totalBytes}/${storage.limitBytes} bytes`);
|
|
87
|
+
* storage.vaults.forEach(v => console.log(`${v.name}: ${v.bytes} bytes`));
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
getStorage(): Promise<StorageUsage>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/resources/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAGrC,wCAAwC;AACxC,MAAM,WAAW,IAAI;IACnB,8B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/**
|
|
3
|
+
* Resource for retrieving user profile and storage information.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const user = await client.user.me();
|
|
8
|
+
* console.log(user.email, user.subscriptionTier);
|
|
9
|
+
*
|
|
10
|
+
* const storage = await client.user.getStorage();
|
|
11
|
+
* console.log(`${storage.totalBytes}/${storage.limitBytes} bytes used`);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export class UserResource {
|
|
15
|
+
http;
|
|
16
|
+
constructor(http) {
|
|
17
|
+
this.http = http;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the current authenticated user's profile.
|
|
21
|
+
*
|
|
22
|
+
* @returns User profile object
|
|
23
|
+
* @throws {AuthenticationError} If not authenticated
|
|
24
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const user = await client.user.me();
|
|
29
|
+
* console.log(user.email, user.subscriptionTier);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
async me() {
|
|
33
|
+
try {
|
|
34
|
+
const data = await this.http.get('users/me').json();
|
|
35
|
+
return data.user;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw await handleError(error, 'User', '');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves storage usage breakdown for the current user.
|
|
43
|
+
*
|
|
44
|
+
* @returns Storage usage statistics including per-vault breakdown
|
|
45
|
+
* @throws {AuthenticationError} If not authenticated
|
|
46
|
+
* @throws {NetworkError} If the request fails due to network issues
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const storage = await client.user.getStorage();
|
|
51
|
+
* console.log(`Using ${storage.totalBytes}/${storage.limitBytes} bytes`);
|
|
52
|
+
* storage.vaults.forEach(v => console.log(`${v.name}: ${v.bytes} bytes`));
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
async getStorage() {
|
|
56
|
+
try {
|
|
57
|
+
return await this.http.get('users/me/storage').json();
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
throw await handleError(error, 'Storage', '');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/resources/user.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAkDjD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,YAAY;IACH;IAApB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE;QACN,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,EAAkB,CAAC;YACpE,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,EAAgB,CAAC;QACtE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF"}
|