@nvisy/sdk 0.2.0 → 0.3.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/CHANGELOG.md +48 -3
- package/README.md +11 -22
- package/dist/auth/index.d.ts +105 -0
- package/dist/auth/index.js +184 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/{workspace-3RLqaMcj.d.ts → auth-CncOz2vx.d.ts} +1309 -944
- package/dist/{client-D6GtLRbO.d.ts → client-DQRisDAK.d.ts} +237 -252
- package/dist/config-L7FKq_q5.d.ts +81 -0
- package/dist/datatypes/index.d.ts +3 -2
- package/dist/index.d.ts +41 -155
- package/dist/index.js +446 -404
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +4 -2
- package/dist/services/index.js +323 -212
- package/dist/services/index.js.map +1 -1
- package/dist/workspace-BjdbMWsa.d.ts +118 -0
- package/package.json +7 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import createClient from 'openapi-fetch';
|
|
|
3
3
|
// src/client.ts
|
|
4
4
|
|
|
5
5
|
// src/config.ts
|
|
6
|
-
var VERSION = "0.
|
|
6
|
+
var VERSION = "0.3.0";
|
|
7
7
|
var DEFAULTS = {
|
|
8
8
|
/**
|
|
9
9
|
* Default base URL for the Nvisy API.
|
|
@@ -16,7 +16,25 @@ var DEFAULTS = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
// src/errors.ts
|
|
19
|
-
var
|
|
19
|
+
var NvisyError = class extends Error {
|
|
20
|
+
/**
|
|
21
|
+
* The error class name.
|
|
22
|
+
*/
|
|
23
|
+
name;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new NvisyError.
|
|
26
|
+
*
|
|
27
|
+
* @param message - The error message
|
|
28
|
+
*/
|
|
29
|
+
constructor(message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = this.constructor.name;
|
|
32
|
+
if (Error.captureStackTrace) {
|
|
33
|
+
Error.captureStackTrace(this, this.constructor);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var NvisyApiError = class extends NvisyError {
|
|
20
38
|
/**
|
|
21
39
|
* The error type identifier (e.g., "ValidationError", "NotFoundError").
|
|
22
40
|
*/
|
|
@@ -39,13 +57,13 @@ var ApiError = class extends Error {
|
|
|
39
57
|
* Field-specific validation errors.
|
|
40
58
|
* Present when the error is due to invalid input data.
|
|
41
59
|
*/
|
|
42
|
-
|
|
60
|
+
validation;
|
|
43
61
|
/**
|
|
44
62
|
* HTTP status code of the response (e.g., 400, 404, 500).
|
|
45
63
|
*/
|
|
46
64
|
statusCode;
|
|
47
65
|
/**
|
|
48
|
-
* Creates a new
|
|
66
|
+
* Creates a new NvisyApiError from an API error response.
|
|
49
67
|
*
|
|
50
68
|
* @param response - The error response from the API
|
|
51
69
|
* @param statusCode - The HTTP status code of the response
|
|
@@ -56,7 +74,7 @@ var ApiError = class extends Error {
|
|
|
56
74
|
this.message = response.message;
|
|
57
75
|
this.resource = response.resource;
|
|
58
76
|
this.suggestion = response.suggestion;
|
|
59
|
-
this.
|
|
77
|
+
this.validation = response.validation;
|
|
60
78
|
this.statusCode = statusCode;
|
|
61
79
|
if (Error.captureStackTrace) {
|
|
62
80
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -110,157 +128,69 @@ var ApiError = class extends Error {
|
|
|
110
128
|
message: this.message,
|
|
111
129
|
resource: this.resource,
|
|
112
130
|
suggestion: this.suggestion,
|
|
113
|
-
|
|
131
|
+
validation: this.validation
|
|
114
132
|
};
|
|
115
133
|
}
|
|
116
134
|
};
|
|
117
|
-
var ClientError = class extends Error {
|
|
118
|
-
/**
|
|
119
|
-
* The error class name (e.g., "ConfigError", "NetworkError").
|
|
120
|
-
*/
|
|
121
|
-
name;
|
|
122
|
-
/**
|
|
123
|
-
* Creates a new ClientError.
|
|
124
|
-
*
|
|
125
|
-
* @param message - The error message
|
|
126
|
-
*/
|
|
127
|
-
constructor(message) {
|
|
128
|
-
super(message);
|
|
129
|
-
this.name = this.constructor.name;
|
|
130
|
-
if (Error.captureStackTrace) {
|
|
131
|
-
Error.captureStackTrace(this, this.constructor);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
var ConfigError = class _ConfigError extends ClientError {
|
|
136
|
-
/**
|
|
137
|
-
* The configuration field that caused the error.
|
|
138
|
-
* May be undefined for general configuration errors.
|
|
139
|
-
*/
|
|
140
|
-
field;
|
|
141
|
-
/**
|
|
142
|
-
* A description of why the configuration is invalid.
|
|
143
|
-
* May be undefined for simple errors.
|
|
144
|
-
*/
|
|
145
|
-
reason;
|
|
146
|
-
/**
|
|
147
|
-
* Creates a new ConfigError.
|
|
148
|
-
*
|
|
149
|
-
* @param message - The error message
|
|
150
|
-
* @param options - Additional error context
|
|
151
|
-
* @param options.field - The field that caused the error
|
|
152
|
-
* @param options.reason - Why the configuration is invalid
|
|
153
|
-
*/
|
|
154
|
-
constructor(message, options) {
|
|
155
|
-
super(message);
|
|
156
|
-
this.field = options?.field;
|
|
157
|
-
this.reason = options?.reason;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Creates a ConfigError for a missing API token.
|
|
161
|
-
*
|
|
162
|
-
* @returns A ConfigError indicating the API token is required
|
|
163
|
-
*
|
|
164
|
-
* @internal
|
|
165
|
-
*/
|
|
166
|
-
static missingApiToken() {
|
|
167
|
-
return new _ConfigError("API token is required", {
|
|
168
|
-
field: "apiToken",
|
|
169
|
-
reason: "API token must be provided in configuration"
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Creates a ConfigError for an invalid configuration field.
|
|
174
|
-
*
|
|
175
|
-
* @param field - The name of the invalid field
|
|
176
|
-
* @param reason - Why the field value is invalid
|
|
177
|
-
* @returns A ConfigError with field and reason context
|
|
178
|
-
*
|
|
179
|
-
* @internal
|
|
180
|
-
*/
|
|
181
|
-
static invalidField(field, reason) {
|
|
182
|
-
return new _ConfigError(`Invalid configuration for ${field}: ${reason}`, {
|
|
183
|
-
field,
|
|
184
|
-
reason
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Creates a ConfigError for a missing required field.
|
|
189
|
-
*
|
|
190
|
-
* @param field - The name of the missing field
|
|
191
|
-
* @returns A ConfigError indicating the field is required
|
|
192
|
-
*
|
|
193
|
-
* @internal
|
|
194
|
-
*/
|
|
195
|
-
static missingField(field) {
|
|
196
|
-
return new _ConfigError(`Missing required configuration field: ${field}`, {
|
|
197
|
-
field,
|
|
198
|
-
reason: "This field is required"
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
var NetworkError = class _NetworkError extends ClientError {
|
|
203
|
-
/**
|
|
204
|
-
* The underlying error that caused this network error.
|
|
205
|
-
* May be undefined if no underlying error is available.
|
|
206
|
-
*/
|
|
207
|
-
cause;
|
|
208
|
-
/**
|
|
209
|
-
* Creates a new NetworkError.
|
|
210
|
-
*
|
|
211
|
-
* @param message - The error message
|
|
212
|
-
* @param cause - The underlying error that caused this failure
|
|
213
|
-
*/
|
|
214
|
-
constructor(message, cause) {
|
|
215
|
-
super(message);
|
|
216
|
-
this.cause = cause;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Creates a NetworkError for connection issues.
|
|
220
|
-
*
|
|
221
|
-
* @param message - Description of the connection problem
|
|
222
|
-
* @param cause - The underlying error
|
|
223
|
-
* @returns A NetworkError for connection failures
|
|
224
|
-
*
|
|
225
|
-
* @internal
|
|
226
|
-
*/
|
|
227
|
-
static connection(message, cause) {
|
|
228
|
-
return new _NetworkError(message, cause);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Creates a NetworkError for aborted requests.
|
|
232
|
-
*
|
|
233
|
-
* @returns A NetworkError indicating the request was aborted
|
|
234
|
-
*
|
|
235
|
-
* @internal
|
|
236
|
-
*/
|
|
237
|
-
static aborted() {
|
|
238
|
-
return new _NetworkError("Request was aborted");
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
135
|
|
|
242
136
|
// src/middleware/error.ts
|
|
243
137
|
var errorMiddleware = {
|
|
244
138
|
async onResponse({ response }) {
|
|
245
139
|
if (!response.ok) {
|
|
246
140
|
const error = await response.clone().json();
|
|
247
|
-
throw new
|
|
141
|
+
throw new NvisyApiError(error, response.status);
|
|
248
142
|
}
|
|
249
143
|
return response;
|
|
250
144
|
},
|
|
251
145
|
onError({ error }) {
|
|
252
146
|
if (error instanceof Error) {
|
|
253
|
-
|
|
254
|
-
throw NetworkError.aborted();
|
|
255
|
-
}
|
|
256
|
-
throw NetworkError.connection(error.message, error);
|
|
147
|
+
throw new NvisyError(error.message);
|
|
257
148
|
}
|
|
258
|
-
throw
|
|
149
|
+
throw new NvisyError("An unknown network error occurred");
|
|
259
150
|
}
|
|
260
151
|
};
|
|
261
152
|
|
|
153
|
+
// src/middleware/logging.ts
|
|
154
|
+
function createLoggingMiddleware() {
|
|
155
|
+
return {
|
|
156
|
+
async onRequest({ request }) {
|
|
157
|
+
const start = performance.now();
|
|
158
|
+
request._startTime = start;
|
|
159
|
+
return request;
|
|
160
|
+
},
|
|
161
|
+
async onResponse({ request, response }) {
|
|
162
|
+
const start = request._startTime ?? performance.now();
|
|
163
|
+
const duration = Math.round(performance.now() - start);
|
|
164
|
+
const url = new URL(request.url);
|
|
165
|
+
console.log(
|
|
166
|
+
`[nvisy] ${request.method} ${url.pathname} ${response.status} (${duration}ms)`
|
|
167
|
+
);
|
|
168
|
+
if (!response.ok) {
|
|
169
|
+
const cloned = response.clone();
|
|
170
|
+
try {
|
|
171
|
+
const body = await cloned.json();
|
|
172
|
+
console.error("[nvisy] Response:", JSON.stringify(body, null, 2));
|
|
173
|
+
} catch {
|
|
174
|
+
const text = await cloned.text();
|
|
175
|
+
if (text) console.error("[nvisy] Response:", text);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return response;
|
|
179
|
+
},
|
|
180
|
+
onError({ request, error }) {
|
|
181
|
+
const start = request._startTime ?? performance.now();
|
|
182
|
+
const duration = Math.round(performance.now() - start);
|
|
183
|
+
const url = new URL(request.url);
|
|
184
|
+
console.error(
|
|
185
|
+
`[nvisy] ${request.method} ${url.pathname} ERROR (${duration}ms):`,
|
|
186
|
+
error instanceof Error ? error.message : error
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
262
192
|
// src/services/account.ts
|
|
263
|
-
var
|
|
193
|
+
var Account = class {
|
|
264
194
|
#api;
|
|
265
195
|
constructor(api) {
|
|
266
196
|
this.#api = api;
|
|
@@ -270,7 +200,7 @@ var AccountService = class {
|
|
|
270
200
|
* @returns Promise that resolves with the account details
|
|
271
201
|
* @throws {ApiError} if the request fails
|
|
272
202
|
*/
|
|
273
|
-
async
|
|
203
|
+
async getAccount() {
|
|
274
204
|
const { data } = await this.#api.GET("/account");
|
|
275
205
|
return data;
|
|
276
206
|
}
|
|
@@ -280,7 +210,7 @@ var AccountService = class {
|
|
|
280
210
|
* @returns Promise that resolves with the updated account
|
|
281
211
|
* @throws {ApiError} if the request fails
|
|
282
212
|
*/
|
|
283
|
-
async
|
|
213
|
+
async updateAccount(updates) {
|
|
284
214
|
const { data } = await this.#api.PATCH("/account", {
|
|
285
215
|
body: updates
|
|
286
216
|
});
|
|
@@ -291,13 +221,13 @@ var AccountService = class {
|
|
|
291
221
|
* @returns Promise that resolves when the account is deleted
|
|
292
222
|
* @throws {ApiError} if the request fails
|
|
293
223
|
*/
|
|
294
|
-
async
|
|
224
|
+
async deleteAccount() {
|
|
295
225
|
await this.#api.DELETE("/account");
|
|
296
226
|
}
|
|
297
227
|
};
|
|
298
228
|
|
|
299
229
|
// src/services/activities.ts
|
|
300
|
-
var
|
|
230
|
+
var Activities = class {
|
|
301
231
|
#api;
|
|
302
232
|
constructor(api) {
|
|
303
233
|
this.#api = api;
|
|
@@ -305,13 +235,13 @@ var ActivitiesService = class {
|
|
|
305
235
|
/**
|
|
306
236
|
* List activities for a workspace
|
|
307
237
|
* @param workspaceId - Workspace ID
|
|
308
|
-
* @param query - Optional
|
|
309
|
-
* @returns Promise that resolves with
|
|
238
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
239
|
+
* @returns Promise that resolves with a paginated list of activities
|
|
310
240
|
* @throws {ApiError} if the request fails
|
|
311
241
|
*/
|
|
312
|
-
async
|
|
242
|
+
async listActivities(workspaceId, query) {
|
|
313
243
|
const { data } = await this.#api.GET(
|
|
314
|
-
"/workspaces/{
|
|
244
|
+
"/workspaces/{workspaceId}/activities/",
|
|
315
245
|
{
|
|
316
246
|
params: { path: { workspaceId }, query }
|
|
317
247
|
}
|
|
@@ -321,7 +251,7 @@ var ActivitiesService = class {
|
|
|
321
251
|
};
|
|
322
252
|
|
|
323
253
|
// src/services/annotations.ts
|
|
324
|
-
var
|
|
254
|
+
var Annotations = class {
|
|
325
255
|
#api;
|
|
326
256
|
constructor(api) {
|
|
327
257
|
this.#api = api;
|
|
@@ -329,12 +259,12 @@ var AnnotationsService = class {
|
|
|
329
259
|
/**
|
|
330
260
|
* List annotations for a file
|
|
331
261
|
* @param fileId - File ID
|
|
332
|
-
* @param query - Optional
|
|
333
|
-
* @returns Promise that resolves with
|
|
262
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
263
|
+
* @returns Promise that resolves with a paginated list of annotations
|
|
334
264
|
* @throws {ApiError} if the request fails
|
|
335
265
|
*/
|
|
336
|
-
async
|
|
337
|
-
const { data } = await this.#api.GET("/files/{
|
|
266
|
+
async listAnnotations(fileId, query) {
|
|
267
|
+
const { data } = await this.#api.GET("/files/{fileId}/annotations/", {
|
|
338
268
|
params: { path: { fileId }, query }
|
|
339
269
|
});
|
|
340
270
|
return data;
|
|
@@ -345,8 +275,8 @@ var AnnotationsService = class {
|
|
|
345
275
|
* @returns Promise that resolves with the annotation details
|
|
346
276
|
* @throws {ApiError} if the request fails
|
|
347
277
|
*/
|
|
348
|
-
async
|
|
349
|
-
const { data } = await this.#api.GET("/annotations/{
|
|
278
|
+
async getAnnotation(annotationId) {
|
|
279
|
+
const { data } = await this.#api.GET("/annotations/{annotationId}", {
|
|
350
280
|
params: { path: { annotationId } }
|
|
351
281
|
});
|
|
352
282
|
return data;
|
|
@@ -358,8 +288,8 @@ var AnnotationsService = class {
|
|
|
358
288
|
* @returns Promise that resolves with the created annotation
|
|
359
289
|
* @throws {ApiError} if the request fails
|
|
360
290
|
*/
|
|
361
|
-
async
|
|
362
|
-
const { data } = await this.#api.POST("/files/{
|
|
291
|
+
async createAnnotation(fileId, annotation) {
|
|
292
|
+
const { data } = await this.#api.POST("/files/{fileId}/annotations/", {
|
|
363
293
|
params: { path: { fileId } },
|
|
364
294
|
body: annotation
|
|
365
295
|
});
|
|
@@ -372,8 +302,8 @@ var AnnotationsService = class {
|
|
|
372
302
|
* @returns Promise that resolves with the updated annotation
|
|
373
303
|
* @throws {ApiError} if the request fails
|
|
374
304
|
*/
|
|
375
|
-
async
|
|
376
|
-
const { data } = await this.#api.PATCH("/annotations/{
|
|
305
|
+
async updateAnnotation(annotationId, updates) {
|
|
306
|
+
const { data } = await this.#api.PATCH("/annotations/{annotationId}", {
|
|
377
307
|
params: { path: { annotationId } },
|
|
378
308
|
body: updates
|
|
379
309
|
});
|
|
@@ -385,53 +315,50 @@ var AnnotationsService = class {
|
|
|
385
315
|
* @returns Promise that resolves when the annotation is deleted
|
|
386
316
|
* @throws {ApiError} if the request fails
|
|
387
317
|
*/
|
|
388
|
-
async
|
|
389
|
-
await this.#api.DELETE("/annotations/{
|
|
318
|
+
async deleteAnnotation(annotationId) {
|
|
319
|
+
await this.#api.DELETE("/annotations/{annotationId}", {
|
|
390
320
|
params: { path: { annotationId } }
|
|
391
321
|
});
|
|
392
322
|
}
|
|
393
323
|
};
|
|
394
324
|
|
|
395
325
|
// src/services/api-tokens.ts
|
|
396
|
-
var
|
|
326
|
+
var ApiTokens = class {
|
|
397
327
|
#api;
|
|
398
328
|
constructor(api) {
|
|
399
329
|
this.#api = api;
|
|
400
330
|
}
|
|
401
331
|
/**
|
|
402
332
|
* List all API tokens for the authenticated account
|
|
403
|
-
* @param
|
|
404
|
-
* @returns Promise that resolves with
|
|
333
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
334
|
+
* @returns Promise that resolves with a paginated list of API tokens
|
|
405
335
|
* @throws {ApiError} if the request fails
|
|
406
336
|
*/
|
|
407
|
-
async
|
|
337
|
+
async listApiTokens(query) {
|
|
408
338
|
const { data } = await this.#api.GET("/api-tokens/", {
|
|
409
|
-
params: { query
|
|
339
|
+
params: { query }
|
|
410
340
|
});
|
|
411
341
|
return data;
|
|
412
342
|
}
|
|
413
343
|
/**
|
|
414
|
-
* Get a specific API token by
|
|
415
|
-
* @param
|
|
344
|
+
* Get a specific API token by token ID
|
|
345
|
+
* @param tokenId - The token identifier
|
|
416
346
|
* @returns Promise that resolves with the API token details
|
|
417
347
|
* @throws {ApiError} if the request fails
|
|
418
348
|
*/
|
|
419
|
-
async
|
|
420
|
-
const { data } = await this.#api.GET(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
params: { path: { access_token: accessToken } }
|
|
424
|
-
}
|
|
425
|
-
);
|
|
349
|
+
async getApiToken(tokenId) {
|
|
350
|
+
const { data } = await this.#api.GET("/api-tokens/{tokenId}/", {
|
|
351
|
+
params: { path: { tokenId } }
|
|
352
|
+
});
|
|
426
353
|
return data;
|
|
427
354
|
}
|
|
428
355
|
/**
|
|
429
356
|
* Create a new API token
|
|
430
357
|
* @param token - Token creation request
|
|
431
|
-
* @returns Promise that resolves with the created token (includes
|
|
358
|
+
* @returns Promise that resolves with the created token (includes JWT, shown only once)
|
|
432
359
|
* @throws {ApiError} if the request fails
|
|
433
360
|
*/
|
|
434
|
-
async
|
|
361
|
+
async createApiToken(token) {
|
|
435
362
|
const { data } = await this.#api.POST("/api-tokens/", {
|
|
436
363
|
body: token
|
|
437
364
|
});
|
|
@@ -439,39 +366,33 @@ var ApiTokensService = class {
|
|
|
439
366
|
}
|
|
440
367
|
/**
|
|
441
368
|
* Update an existing API token
|
|
442
|
-
* @param
|
|
369
|
+
* @param tokenId - The token identifier
|
|
443
370
|
* @param updates - Token update request
|
|
444
371
|
* @returns Promise that resolves with the updated token
|
|
445
372
|
* @throws {ApiError} if the request fails
|
|
446
373
|
*/
|
|
447
|
-
async
|
|
448
|
-
const { data } = await this.#api.PATCH(
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
body: updates
|
|
453
|
-
}
|
|
454
|
-
);
|
|
374
|
+
async updateApiToken(tokenId, updates) {
|
|
375
|
+
const { data } = await this.#api.PATCH("/api-tokens/{tokenId}/", {
|
|
376
|
+
params: { path: { tokenId } },
|
|
377
|
+
body: updates
|
|
378
|
+
});
|
|
455
379
|
return data;
|
|
456
380
|
}
|
|
457
381
|
/**
|
|
458
382
|
* Revoke an API token
|
|
459
|
-
* @param
|
|
383
|
+
* @param tokenId - The token identifier
|
|
460
384
|
* @returns Promise that resolves when the token is revoked
|
|
461
385
|
* @throws {ApiError} if the request fails
|
|
462
386
|
*/
|
|
463
|
-
async
|
|
464
|
-
await this.#api.DELETE(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
params: { path: { access_token: accessToken } }
|
|
468
|
-
}
|
|
469
|
-
);
|
|
387
|
+
async revokeApiToken(tokenId) {
|
|
388
|
+
await this.#api.DELETE("/api-tokens/{tokenId}/", {
|
|
389
|
+
params: { path: { tokenId } }
|
|
390
|
+
});
|
|
470
391
|
}
|
|
471
392
|
};
|
|
472
393
|
|
|
473
394
|
// src/services/auth.ts
|
|
474
|
-
var
|
|
395
|
+
var Auth = class {
|
|
475
396
|
#api;
|
|
476
397
|
constructor(api) {
|
|
477
398
|
this.#api = api;
|
|
@@ -482,7 +403,7 @@ var AuthService = class {
|
|
|
482
403
|
* @returns Promise that resolves with the auth response containing access token
|
|
483
404
|
* @throws {ApiError} if the request fails
|
|
484
405
|
*/
|
|
485
|
-
async
|
|
406
|
+
async loginAccount(credentials) {
|
|
486
407
|
const { data } = await this.#api.POST("/auth/login", {
|
|
487
408
|
body: credentials
|
|
488
409
|
});
|
|
@@ -490,20 +411,28 @@ var AuthService = class {
|
|
|
490
411
|
}
|
|
491
412
|
/**
|
|
492
413
|
* Sign up a new account
|
|
493
|
-
* @param
|
|
414
|
+
* @param credentials - Signup details
|
|
494
415
|
* @returns Promise that resolves with the auth response containing access token
|
|
495
416
|
* @throws {ApiError} if the request fails
|
|
496
417
|
*/
|
|
497
|
-
async
|
|
418
|
+
async signupAccount(credentials) {
|
|
498
419
|
const { data } = await this.#api.POST("/auth/signup", {
|
|
499
|
-
body:
|
|
420
|
+
body: credentials
|
|
500
421
|
});
|
|
501
422
|
return data;
|
|
502
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Logout and invalidate the current access token
|
|
426
|
+
* @returns Promise that resolves when logout is complete
|
|
427
|
+
* @throws {ApiError} if the request fails
|
|
428
|
+
*/
|
|
429
|
+
async logoutAccount() {
|
|
430
|
+
await this.#api.POST("/auth/logout");
|
|
431
|
+
}
|
|
503
432
|
};
|
|
504
433
|
|
|
505
434
|
// src/services/comments.ts
|
|
506
|
-
var
|
|
435
|
+
var Comments = class {
|
|
507
436
|
#api;
|
|
508
437
|
constructor(api) {
|
|
509
438
|
this.#api = api;
|
|
@@ -511,12 +440,12 @@ var CommentsService = class {
|
|
|
511
440
|
/**
|
|
512
441
|
* List all comments on a file
|
|
513
442
|
* @param fileId - File ID
|
|
514
|
-
* @param query - Optional
|
|
515
|
-
* @returns Promise that resolves with
|
|
443
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
444
|
+
* @returns Promise that resolves with a paginated list of comments
|
|
516
445
|
* @throws {ApiError} if the request fails
|
|
517
446
|
*/
|
|
518
|
-
async
|
|
519
|
-
const { data } = await this.#api.GET("/files/{
|
|
447
|
+
async listComments(fileId, query) {
|
|
448
|
+
const { data } = await this.#api.GET("/files/{fileId}/comments", {
|
|
520
449
|
params: { path: { fileId }, query }
|
|
521
450
|
});
|
|
522
451
|
return data;
|
|
@@ -528,29 +457,42 @@ var CommentsService = class {
|
|
|
528
457
|
* @returns Promise that resolves with the created comment
|
|
529
458
|
* @throws {ApiError} if the request fails
|
|
530
459
|
*/
|
|
531
|
-
async
|
|
532
|
-
const { data } = await this.#api.POST("/files/{
|
|
460
|
+
async createComment(fileId, comment) {
|
|
461
|
+
const { data } = await this.#api.POST("/files/{fileId}/comments", {
|
|
533
462
|
params: { path: { fileId } },
|
|
534
463
|
body: comment
|
|
535
464
|
});
|
|
536
465
|
return data;
|
|
537
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* Update a comment
|
|
469
|
+
* @param commentId - Comment ID
|
|
470
|
+
* @param updates - Comment update request
|
|
471
|
+
* @returns Promise that resolves with the updated comment
|
|
472
|
+
* @throws {ApiError} if the request fails
|
|
473
|
+
*/
|
|
474
|
+
async updateComment(commentId, updates) {
|
|
475
|
+
const { data } = await this.#api.PATCH("/comments/{commentId}", {
|
|
476
|
+
params: { path: { commentId } },
|
|
477
|
+
body: updates
|
|
478
|
+
});
|
|
479
|
+
return data;
|
|
480
|
+
}
|
|
538
481
|
/**
|
|
539
482
|
* Delete a comment
|
|
540
|
-
* @param fileId - File ID
|
|
541
483
|
* @param commentId - Comment ID
|
|
542
484
|
* @returns Promise that resolves when the comment is deleted
|
|
543
485
|
* @throws {ApiError} if the request fails
|
|
544
486
|
*/
|
|
545
|
-
async
|
|
546
|
-
await this.#api.DELETE("/
|
|
547
|
-
params: { path: {
|
|
487
|
+
async deleteComment(commentId) {
|
|
488
|
+
await this.#api.DELETE("/comments/{commentId}", {
|
|
489
|
+
params: { path: { commentId } }
|
|
548
490
|
});
|
|
549
491
|
}
|
|
550
492
|
};
|
|
551
493
|
|
|
552
494
|
// src/services/documents.ts
|
|
553
|
-
var
|
|
495
|
+
var Documents = class {
|
|
554
496
|
#api;
|
|
555
497
|
constructor(api) {
|
|
556
498
|
this.#api = api;
|
|
@@ -558,13 +500,13 @@ var DocumentsService = class {
|
|
|
558
500
|
/**
|
|
559
501
|
* List documents in a workspace
|
|
560
502
|
* @param workspaceId - Workspace ID
|
|
561
|
-
* @param query - Optional
|
|
562
|
-
* @returns Promise that resolves with
|
|
503
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
504
|
+
* @returns Promise that resolves with a paginated list of documents
|
|
563
505
|
* @throws {ApiError} if the request fails
|
|
564
506
|
*/
|
|
565
|
-
async
|
|
507
|
+
async listDocuments(workspaceId, query) {
|
|
566
508
|
const { data } = await this.#api.GET(
|
|
567
|
-
"/workspaces/{
|
|
509
|
+
"/workspaces/{workspaceId}/documents",
|
|
568
510
|
{
|
|
569
511
|
params: { path: { workspaceId }, query }
|
|
570
512
|
}
|
|
@@ -577,8 +519,8 @@ var DocumentsService = class {
|
|
|
577
519
|
* @returns Promise that resolves with the document details
|
|
578
520
|
* @throws {ApiError} if the request fails
|
|
579
521
|
*/
|
|
580
|
-
async
|
|
581
|
-
const { data } = await this.#api.GET("/documents/{
|
|
522
|
+
async getDocument(documentId) {
|
|
523
|
+
const { data } = await this.#api.GET("/documents/{documentId}", {
|
|
582
524
|
params: { path: { documentId } }
|
|
583
525
|
});
|
|
584
526
|
return data;
|
|
@@ -590,9 +532,9 @@ var DocumentsService = class {
|
|
|
590
532
|
* @returns Promise that resolves with the created document
|
|
591
533
|
* @throws {ApiError} if the request fails
|
|
592
534
|
*/
|
|
593
|
-
async
|
|
535
|
+
async createDocument(workspaceId, document) {
|
|
594
536
|
const { data } = await this.#api.POST(
|
|
595
|
-
"/workspaces/{
|
|
537
|
+
"/workspaces/{workspaceId}/documents",
|
|
596
538
|
{
|
|
597
539
|
params: { path: { workspaceId } },
|
|
598
540
|
body: document
|
|
@@ -607,8 +549,8 @@ var DocumentsService = class {
|
|
|
607
549
|
* @returns Promise that resolves with the updated document
|
|
608
550
|
* @throws {ApiError} if the request fails
|
|
609
551
|
*/
|
|
610
|
-
async
|
|
611
|
-
const { data } = await this.#api.PATCH("/documents/{
|
|
552
|
+
async updateDocument(documentId, updates) {
|
|
553
|
+
const { data } = await this.#api.PATCH("/documents/{documentId}", {
|
|
612
554
|
params: { path: { documentId } },
|
|
613
555
|
body: updates
|
|
614
556
|
});
|
|
@@ -620,40 +562,76 @@ var DocumentsService = class {
|
|
|
620
562
|
* @returns Promise that resolves when the document is deleted
|
|
621
563
|
* @throws {ApiError} if the request fails
|
|
622
564
|
*/
|
|
623
|
-
async
|
|
624
|
-
await this.#api.DELETE("/documents/{
|
|
565
|
+
async deleteDocument(documentId) {
|
|
566
|
+
await this.#api.DELETE("/documents/{documentId}", {
|
|
625
567
|
params: { path: { documentId } }
|
|
626
568
|
});
|
|
627
569
|
}
|
|
628
570
|
};
|
|
629
571
|
|
|
630
572
|
// src/services/files.ts
|
|
631
|
-
var
|
|
573
|
+
var Files = class {
|
|
632
574
|
#api;
|
|
633
575
|
constructor(api) {
|
|
634
576
|
this.#api = api;
|
|
635
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* Upload one or more files to a workspace
|
|
580
|
+
* @param workspaceId - Workspace ID
|
|
581
|
+
* @param files - File or array of files to upload
|
|
582
|
+
* @returns Promise that resolves with the uploaded file metadata
|
|
583
|
+
* @throws {ApiError} if the request fails
|
|
584
|
+
*/
|
|
585
|
+
async uploadFiles(workspaceId, files) {
|
|
586
|
+
const formData = new FormData();
|
|
587
|
+
const fileArray = Array.isArray(files) ? files : [files];
|
|
588
|
+
for (const file of fileArray) {
|
|
589
|
+
const name = file instanceof File ? file.name : "file";
|
|
590
|
+
formData.append("files", file, name);
|
|
591
|
+
}
|
|
592
|
+
const { data } = await this.#api.POST("/workspaces/{workspaceId}/files/", {
|
|
593
|
+
params: { path: { workspaceId } },
|
|
594
|
+
// Schema types multipart as unknown[], but openapi-fetch needs FormData.
|
|
595
|
+
body: formData,
|
|
596
|
+
bodySerializer: (formData2) => formData2,
|
|
597
|
+
// Remove Content-Type so browser sets multipart/form-data with boundary.
|
|
598
|
+
headers: { "Content-Type": null }
|
|
599
|
+
});
|
|
600
|
+
return data;
|
|
601
|
+
}
|
|
636
602
|
/**
|
|
637
603
|
* List files in a workspace
|
|
638
604
|
* @param workspaceId - Workspace ID
|
|
639
|
-
* @param query - Optional query parameters (formats,
|
|
640
|
-
* @returns Promise that resolves with
|
|
605
|
+
* @param query - Optional query parameters (formats, limit, after)
|
|
606
|
+
* @returns Promise that resolves with a paginated list of files
|
|
641
607
|
* @throws {ApiError} if the request fails
|
|
642
608
|
*/
|
|
643
|
-
async
|
|
644
|
-
const { data } = await this.#api.GET("/workspaces/{
|
|
609
|
+
async listFiles(workspaceId, query) {
|
|
610
|
+
const { data } = await this.#api.GET("/workspaces/{workspaceId}/files/", {
|
|
645
611
|
params: { path: { workspaceId }, query }
|
|
646
612
|
});
|
|
647
613
|
return data;
|
|
648
614
|
}
|
|
615
|
+
/**
|
|
616
|
+
* Get file metadata by ID
|
|
617
|
+
* @param fileId - File ID
|
|
618
|
+
* @returns Promise that resolves with the file metadata
|
|
619
|
+
* @throws {ApiError} if the request fails
|
|
620
|
+
*/
|
|
621
|
+
async getFile(fileId) {
|
|
622
|
+
const { data } = await this.#api.GET("/files/{fileId}", {
|
|
623
|
+
params: { path: { fileId } }
|
|
624
|
+
});
|
|
625
|
+
return data;
|
|
626
|
+
}
|
|
649
627
|
/**
|
|
650
628
|
* Download a file by ID
|
|
651
629
|
* @param fileId - File ID
|
|
652
630
|
* @returns Promise that resolves with the file response
|
|
653
631
|
* @throws {ApiError} if the request fails
|
|
654
632
|
*/
|
|
655
|
-
async
|
|
656
|
-
const { response } = await this.#api.GET("/files/{
|
|
633
|
+
async downloadFile(fileId) {
|
|
634
|
+
const { response } = await this.#api.GET("/files/{fileId}/content", {
|
|
657
635
|
params: { path: { fileId } },
|
|
658
636
|
parseAs: "stream"
|
|
659
637
|
});
|
|
@@ -666,8 +644,8 @@ var FilesService = class {
|
|
|
666
644
|
* @returns Promise that resolves with the updated file
|
|
667
645
|
* @throws {ApiError} if the request fails
|
|
668
646
|
*/
|
|
669
|
-
async
|
|
670
|
-
const { data } = await this.#api.PATCH("/files/{
|
|
647
|
+
async updateFile(fileId, updates) {
|
|
648
|
+
const { data } = await this.#api.PATCH("/files/{fileId}", {
|
|
671
649
|
params: { path: { fileId } },
|
|
672
650
|
body: updates
|
|
673
651
|
});
|
|
@@ -679,21 +657,21 @@ var FilesService = class {
|
|
|
679
657
|
* @returns Promise that resolves when the file is deleted
|
|
680
658
|
* @throws {ApiError} if the request fails
|
|
681
659
|
*/
|
|
682
|
-
async
|
|
683
|
-
await this.#api.DELETE("/files/{
|
|
660
|
+
async deleteFile(fileId) {
|
|
661
|
+
await this.#api.DELETE("/files/{fileId}", {
|
|
684
662
|
params: { path: { fileId } }
|
|
685
663
|
});
|
|
686
664
|
}
|
|
687
665
|
/**
|
|
688
|
-
* Download
|
|
666
|
+
* Download files as an archive
|
|
689
667
|
* @param workspaceId - Workspace ID
|
|
690
|
-
* @param request - Download request with file IDs
|
|
691
|
-
* @returns Promise that resolves with the
|
|
668
|
+
* @param request - Download request with format and optional file IDs
|
|
669
|
+
* @returns Promise that resolves with the archive response
|
|
692
670
|
* @throws {ApiError} if the request fails
|
|
693
671
|
*/
|
|
694
|
-
async
|
|
695
|
-
const { response } = await this.#api.
|
|
696
|
-
"/workspaces/{
|
|
672
|
+
async downloadFiles(workspaceId, request) {
|
|
673
|
+
const { response } = await this.#api.GET(
|
|
674
|
+
"/workspaces/{workspaceId}/files/batch",
|
|
697
675
|
{
|
|
698
676
|
params: { path: { workspaceId } },
|
|
699
677
|
body: request,
|
|
@@ -703,27 +681,22 @@ var FilesService = class {
|
|
|
703
681
|
return response;
|
|
704
682
|
}
|
|
705
683
|
/**
|
|
706
|
-
*
|
|
684
|
+
* Delete multiple files
|
|
707
685
|
* @param workspaceId - Workspace ID
|
|
708
|
-
* @param request -
|
|
709
|
-
* @returns Promise that resolves
|
|
686
|
+
* @param request - Delete request with file IDs
|
|
687
|
+
* @returns Promise that resolves when the files are deleted
|
|
710
688
|
* @throws {ApiError} if the request fails
|
|
711
689
|
*/
|
|
712
|
-
async
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
body: request,
|
|
718
|
-
parseAs: "stream"
|
|
719
|
-
}
|
|
720
|
-
);
|
|
721
|
-
return response;
|
|
690
|
+
async deleteFiles(workspaceId, request) {
|
|
691
|
+
await this.#api.DELETE("/workspaces/{workspaceId}/files/batch", {
|
|
692
|
+
params: { path: { workspaceId } },
|
|
693
|
+
body: request
|
|
694
|
+
});
|
|
722
695
|
}
|
|
723
696
|
};
|
|
724
697
|
|
|
725
698
|
// src/services/integrations.ts
|
|
726
|
-
var
|
|
699
|
+
var Integrations = class {
|
|
727
700
|
#api;
|
|
728
701
|
constructor(api) {
|
|
729
702
|
this.#api = api;
|
|
@@ -731,13 +704,13 @@ var IntegrationsService = class {
|
|
|
731
704
|
/**
|
|
732
705
|
* List integrations for a workspace
|
|
733
706
|
* @param workspaceId - Workspace ID
|
|
734
|
-
* @param query - Optional
|
|
735
|
-
* @returns Promise that resolves with
|
|
707
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
708
|
+
* @returns Promise that resolves with a paginated list of integrations
|
|
736
709
|
* @throws {ApiError} if the request fails
|
|
737
710
|
*/
|
|
738
|
-
async
|
|
711
|
+
async listIntegrations(workspaceId, query) {
|
|
739
712
|
const { data } = await this.#api.GET(
|
|
740
|
-
"/workspaces/{
|
|
713
|
+
"/workspaces/{workspaceId}/integrations/",
|
|
741
714
|
{
|
|
742
715
|
params: { path: { workspaceId }, query }
|
|
743
716
|
}
|
|
@@ -750,8 +723,8 @@ var IntegrationsService = class {
|
|
|
750
723
|
* @returns Promise that resolves with the integration details
|
|
751
724
|
* @throws {ApiError} if the request fails
|
|
752
725
|
*/
|
|
753
|
-
async
|
|
754
|
-
const { data } = await this.#api.GET("/integrations/{
|
|
726
|
+
async getIntegration(integrationId) {
|
|
727
|
+
const { data } = await this.#api.GET("/integrations/{integrationId}/", {
|
|
755
728
|
params: { path: { integrationId } }
|
|
756
729
|
});
|
|
757
730
|
return data;
|
|
@@ -763,9 +736,9 @@ var IntegrationsService = class {
|
|
|
763
736
|
* @returns Promise that resolves with the created integration
|
|
764
737
|
* @throws {ApiError} if the request fails
|
|
765
738
|
*/
|
|
766
|
-
async
|
|
739
|
+
async createIntegration(workspaceId, integration) {
|
|
767
740
|
const { data } = await this.#api.POST(
|
|
768
|
-
"/workspaces/{
|
|
741
|
+
"/workspaces/{workspaceId}/integrations/",
|
|
769
742
|
{
|
|
770
743
|
params: { path: { workspaceId } },
|
|
771
744
|
body: integration
|
|
@@ -780,8 +753,8 @@ var IntegrationsService = class {
|
|
|
780
753
|
* @returns Promise that resolves with the updated integration
|
|
781
754
|
* @throws {ApiError} if the request fails
|
|
782
755
|
*/
|
|
783
|
-
async
|
|
784
|
-
const { data } = await this.#api.PUT("/integrations/{
|
|
756
|
+
async updateIntegration(integrationId, updates) {
|
|
757
|
+
const { data } = await this.#api.PUT("/integrations/{integrationId}/", {
|
|
785
758
|
params: { path: { integrationId } },
|
|
786
759
|
body: updates
|
|
787
760
|
});
|
|
@@ -794,9 +767,9 @@ var IntegrationsService = class {
|
|
|
794
767
|
* @returns Promise that resolves with the updated integration
|
|
795
768
|
* @throws {ApiError} if the request fails
|
|
796
769
|
*/
|
|
797
|
-
async
|
|
770
|
+
async updateIntegrationCredentials(integrationId, credentials) {
|
|
798
771
|
const { data } = await this.#api.PATCH(
|
|
799
|
-
"/integrations/{
|
|
772
|
+
"/integrations/{integrationId}/credentials/",
|
|
800
773
|
{
|
|
801
774
|
params: { path: { integrationId } },
|
|
802
775
|
body: credentials
|
|
@@ -810,15 +783,15 @@ var IntegrationsService = class {
|
|
|
810
783
|
* @returns Promise that resolves when the integration is deleted
|
|
811
784
|
* @throws {ApiError} if the request fails
|
|
812
785
|
*/
|
|
813
|
-
async
|
|
814
|
-
await this.#api.DELETE("/integrations/{
|
|
786
|
+
async deleteIntegration(integrationId) {
|
|
787
|
+
await this.#api.DELETE("/integrations/{integrationId}/", {
|
|
815
788
|
params: { path: { integrationId } }
|
|
816
789
|
});
|
|
817
790
|
}
|
|
818
791
|
};
|
|
819
792
|
|
|
820
793
|
// src/services/invites.ts
|
|
821
|
-
var
|
|
794
|
+
var Invites = class {
|
|
822
795
|
#api;
|
|
823
796
|
constructor(api) {
|
|
824
797
|
this.#api = api;
|
|
@@ -826,17 +799,14 @@ var InvitesService = class {
|
|
|
826
799
|
/**
|
|
827
800
|
* List all invitations for a workspace
|
|
828
801
|
* @param workspaceId - Workspace ID
|
|
829
|
-
* @param query - Optional query parameters (role, sortBy, order,
|
|
830
|
-
* @returns Promise that resolves with
|
|
802
|
+
* @param query - Optional query parameters (role, sortBy, order, limit, after)
|
|
803
|
+
* @returns Promise that resolves with a paginated list of invitations
|
|
831
804
|
* @throws {ApiError} if the request fails
|
|
832
805
|
*/
|
|
833
|
-
async
|
|
834
|
-
const { data } = await this.#api.GET(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
params: { path: { workspaceId }, query }
|
|
838
|
-
}
|
|
839
|
-
);
|
|
806
|
+
async listInvites(workspaceId, query) {
|
|
807
|
+
const { data } = await this.#api.GET("/workspaces/{workspaceId}/invites/", {
|
|
808
|
+
params: { path: { workspaceId }, query }
|
|
809
|
+
});
|
|
840
810
|
return data;
|
|
841
811
|
}
|
|
842
812
|
/**
|
|
@@ -846,9 +816,9 @@ var InvitesService = class {
|
|
|
846
816
|
* @returns Promise that resolves with the created invitation
|
|
847
817
|
* @throws {ApiError} if the request fails
|
|
848
818
|
*/
|
|
849
|
-
async
|
|
819
|
+
async sendInvite(workspaceId, invite) {
|
|
850
820
|
const { data } = await this.#api.POST(
|
|
851
|
-
"/workspaces/{
|
|
821
|
+
"/workspaces/{workspaceId}/invites/",
|
|
852
822
|
{
|
|
853
823
|
params: { path: { workspaceId } },
|
|
854
824
|
body: invite
|
|
@@ -862,8 +832,8 @@ var InvitesService = class {
|
|
|
862
832
|
* @returns Promise that resolves when the invitation is canceled
|
|
863
833
|
* @throws {ApiError} if the request fails
|
|
864
834
|
*/
|
|
865
|
-
async
|
|
866
|
-
await this.#api.DELETE("/invites/{
|
|
835
|
+
async cancelInvite(inviteId) {
|
|
836
|
+
await this.#api.DELETE("/invites/{inviteId}/", {
|
|
867
837
|
params: { path: { inviteId } }
|
|
868
838
|
});
|
|
869
839
|
}
|
|
@@ -874,8 +844,8 @@ var InvitesService = class {
|
|
|
874
844
|
* @returns Promise that resolves with the updated invitation
|
|
875
845
|
* @throws {ApiError} if the request fails
|
|
876
846
|
*/
|
|
877
|
-
async
|
|
878
|
-
const { data } = await this.#api.
|
|
847
|
+
async replyToInvite(inviteId, reply) {
|
|
848
|
+
const { data } = await this.#api.POST("/invites/{inviteId}/", {
|
|
879
849
|
params: { path: { inviteId } },
|
|
880
850
|
body: reply
|
|
881
851
|
});
|
|
@@ -888,9 +858,9 @@ var InvitesService = class {
|
|
|
888
858
|
* @returns Promise that resolves with the generated invite code
|
|
889
859
|
* @throws {ApiError} if the request fails
|
|
890
860
|
*/
|
|
891
|
-
async
|
|
861
|
+
async generateInviteCode(workspaceId, options) {
|
|
892
862
|
const { data } = await this.#api.POST(
|
|
893
|
-
"/workspaces/{
|
|
863
|
+
"/workspaces/{workspaceId}/invites/code/",
|
|
894
864
|
{
|
|
895
865
|
params: { path: { workspaceId } },
|
|
896
866
|
body: options
|
|
@@ -899,13 +869,27 @@ var InvitesService = class {
|
|
|
899
869
|
return data;
|
|
900
870
|
}
|
|
901
871
|
/**
|
|
902
|
-
*
|
|
872
|
+
* Reply to an invite code (accept or decline)
|
|
903
873
|
* @param inviteCode - The invite code
|
|
904
|
-
* @
|
|
874
|
+
* @param reply - Optional reply request (defaults to accept if not provided)
|
|
875
|
+
* @returns Promise that resolves with the member details if accepted, null if declined
|
|
905
876
|
* @throws {ApiError} if the request fails
|
|
906
877
|
*/
|
|
907
|
-
async
|
|
908
|
-
const { data } = await this.#api.POST("/invites/{
|
|
878
|
+
async replyToInviteCode(inviteCode, reply) {
|
|
879
|
+
const { data } = await this.#api.POST("/invites/code/{inviteCode}/", {
|
|
880
|
+
params: { path: { inviteCode } },
|
|
881
|
+
body: reply ?? null
|
|
882
|
+
});
|
|
883
|
+
return data;
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Preview an invite code without joining
|
|
887
|
+
* @param inviteCode - The invite code
|
|
888
|
+
* @returns Promise that resolves with the invite preview details
|
|
889
|
+
* @throws {ApiError} if the request fails
|
|
890
|
+
*/
|
|
891
|
+
async previewInvite(inviteCode) {
|
|
892
|
+
const { data } = await this.#api.GET("/invites/code/{inviteCode}/", {
|
|
909
893
|
params: { path: { inviteCode } }
|
|
910
894
|
});
|
|
911
895
|
return data;
|
|
@@ -913,7 +897,7 @@ var InvitesService = class {
|
|
|
913
897
|
};
|
|
914
898
|
|
|
915
899
|
// src/services/members.ts
|
|
916
|
-
var
|
|
900
|
+
var Members = class {
|
|
917
901
|
#api;
|
|
918
902
|
constructor(api) {
|
|
919
903
|
this.#api = api;
|
|
@@ -921,17 +905,14 @@ var MembersService = class {
|
|
|
921
905
|
/**
|
|
922
906
|
* List members of a workspace
|
|
923
907
|
* @param workspaceId - Workspace ID
|
|
924
|
-
* @param query - Optional query parameters (role, has2fa, sortBy, order,
|
|
925
|
-
* @returns Promise that resolves with
|
|
908
|
+
* @param query - Optional query parameters (role, has2fa, sortBy, order, limit, after)
|
|
909
|
+
* @returns Promise that resolves with a paginated list of members
|
|
926
910
|
* @throws {ApiError} if the request fails
|
|
927
911
|
*/
|
|
928
|
-
async
|
|
929
|
-
const { data } = await this.#api.GET(
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
params: { path: { workspaceId }, query }
|
|
933
|
-
}
|
|
934
|
-
);
|
|
912
|
+
async listMembers(workspaceId, query) {
|
|
913
|
+
const { data } = await this.#api.GET("/workspaces/{workspaceId}/members/", {
|
|
914
|
+
params: { path: { workspaceId }, query }
|
|
915
|
+
});
|
|
935
916
|
return data;
|
|
936
917
|
}
|
|
937
918
|
/**
|
|
@@ -941,11 +922,13 @@ var MembersService = class {
|
|
|
941
922
|
* @returns Promise that resolves with the member details
|
|
942
923
|
* @throws {ApiError} if the request fails
|
|
943
924
|
*/
|
|
944
|
-
async
|
|
925
|
+
async getMember(workspaceId, accountId) {
|
|
945
926
|
const { data } = await this.#api.GET(
|
|
946
|
-
"/workspaces/{
|
|
927
|
+
"/workspaces/{workspaceId}/members/{accountId}/",
|
|
947
928
|
{
|
|
948
|
-
params: {
|
|
929
|
+
params: {
|
|
930
|
+
path: { workspaceId, accountId }
|
|
931
|
+
}
|
|
949
932
|
}
|
|
950
933
|
);
|
|
951
934
|
return data;
|
|
@@ -954,16 +937,18 @@ var MembersService = class {
|
|
|
954
937
|
* Update a member's role
|
|
955
938
|
* @param workspaceId - Workspace ID
|
|
956
939
|
* @param accountId - Account ID
|
|
957
|
-
* @param
|
|
940
|
+
* @param updates - New role for the member
|
|
958
941
|
* @returns Promise that resolves with the updated member
|
|
959
942
|
* @throws {ApiError} if the request fails
|
|
960
943
|
*/
|
|
961
|
-
async
|
|
944
|
+
async updateMember(workspaceId, accountId, updates) {
|
|
962
945
|
const { data } = await this.#api.PATCH(
|
|
963
|
-
"/workspaces/{
|
|
946
|
+
"/workspaces/{workspaceId}/members/{accountId}/role",
|
|
964
947
|
{
|
|
965
|
-
params: {
|
|
966
|
-
|
|
948
|
+
params: {
|
|
949
|
+
path: { workspaceId, accountId }
|
|
950
|
+
},
|
|
951
|
+
body: updates
|
|
967
952
|
}
|
|
968
953
|
);
|
|
969
954
|
return data;
|
|
@@ -975,8 +960,8 @@ var MembersService = class {
|
|
|
975
960
|
* @returns Promise that resolves when the member is removed
|
|
976
961
|
* @throws {ApiError} if the request fails
|
|
977
962
|
*/
|
|
978
|
-
async
|
|
979
|
-
await this.#api.DELETE("/workspaces/{
|
|
963
|
+
async removeMember(workspaceId, accountId) {
|
|
964
|
+
await this.#api.DELETE("/workspaces/{workspaceId}/members/{accountId}/", {
|
|
980
965
|
params: { path: { workspaceId, accountId } }
|
|
981
966
|
});
|
|
982
967
|
}
|
|
@@ -986,35 +971,44 @@ var MembersService = class {
|
|
|
986
971
|
* @returns Promise that resolves when the member has left
|
|
987
972
|
* @throws {ApiError} if the request fails
|
|
988
973
|
*/
|
|
989
|
-
async
|
|
990
|
-
await this.#api.POST("/workspaces/{
|
|
974
|
+
async leaveWorkspace(workspaceId) {
|
|
975
|
+
await this.#api.POST("/workspaces/{workspaceId}/members/leave", {
|
|
991
976
|
params: { path: { workspaceId } }
|
|
992
977
|
});
|
|
993
978
|
}
|
|
994
979
|
};
|
|
995
980
|
|
|
996
981
|
// src/services/notifications.ts
|
|
997
|
-
var
|
|
982
|
+
var Notifications = class {
|
|
998
983
|
#api;
|
|
999
984
|
constructor(api) {
|
|
1000
985
|
this.#api = api;
|
|
1001
986
|
}
|
|
1002
987
|
/**
|
|
1003
988
|
* List notifications for the authenticated account
|
|
1004
|
-
* @param query - Optional
|
|
1005
|
-
* @returns Promise that resolves with
|
|
989
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
990
|
+
* @returns Promise that resolves with a paginated list of notifications
|
|
1006
991
|
* @throws {ApiError} if the request fails
|
|
1007
992
|
*/
|
|
1008
|
-
async
|
|
993
|
+
async listNotifications(query) {
|
|
1009
994
|
const { data } = await this.#api.GET("/notifications/", {
|
|
1010
995
|
params: { query }
|
|
1011
996
|
});
|
|
1012
997
|
return data;
|
|
1013
998
|
}
|
|
999
|
+
/**
|
|
1000
|
+
* Get the unread notifications count for the authenticated account
|
|
1001
|
+
* @returns Promise that resolves with the unread status
|
|
1002
|
+
* @throws {ApiError} if the request fails
|
|
1003
|
+
*/
|
|
1004
|
+
async getUnreadNotificationsStatus() {
|
|
1005
|
+
const { data } = await this.#api.GET("/notifications/unread");
|
|
1006
|
+
return data;
|
|
1007
|
+
}
|
|
1014
1008
|
};
|
|
1015
1009
|
|
|
1016
1010
|
// src/services/runs.ts
|
|
1017
|
-
var
|
|
1011
|
+
var Runs = class {
|
|
1018
1012
|
#api;
|
|
1019
1013
|
constructor(api) {
|
|
1020
1014
|
this.#api = api;
|
|
@@ -1022,12 +1016,12 @@ var RunsService = class {
|
|
|
1022
1016
|
/**
|
|
1023
1017
|
* List integration runs for a workspace
|
|
1024
1018
|
* @param workspaceId - Workspace ID
|
|
1025
|
-
* @param query - Optional
|
|
1026
|
-
* @returns Promise that resolves with
|
|
1019
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
1020
|
+
* @returns Promise that resolves with a paginated list of integration runs
|
|
1027
1021
|
* @throws {ApiError} if the request fails
|
|
1028
1022
|
*/
|
|
1029
|
-
async
|
|
1030
|
-
const { data } = await this.#api.GET("/workspaces/{
|
|
1023
|
+
async listRuns(workspaceId, query) {
|
|
1024
|
+
const { data } = await this.#api.GET("/workspaces/{workspaceId}/runs/", {
|
|
1031
1025
|
params: { path: { workspaceId }, query }
|
|
1032
1026
|
});
|
|
1033
1027
|
return data;
|
|
@@ -1038,8 +1032,8 @@ var RunsService = class {
|
|
|
1038
1032
|
* @returns Promise that resolves with the integration run details
|
|
1039
1033
|
* @throws {ApiError} if the request fails
|
|
1040
1034
|
*/
|
|
1041
|
-
async
|
|
1042
|
-
const { data } = await this.#api.GET("/runs/{
|
|
1035
|
+
async getRun(runId) {
|
|
1036
|
+
const { data } = await this.#api.GET("/runs/{runId}", {
|
|
1043
1037
|
params: { path: { runId } }
|
|
1044
1038
|
});
|
|
1045
1039
|
return data;
|
|
@@ -1047,7 +1041,7 @@ var RunsService = class {
|
|
|
1047
1041
|
};
|
|
1048
1042
|
|
|
1049
1043
|
// src/services/status.ts
|
|
1050
|
-
var
|
|
1044
|
+
var Status = class {
|
|
1051
1045
|
#api;
|
|
1052
1046
|
constructor(api) {
|
|
1053
1047
|
this.#api = api;
|
|
@@ -1057,7 +1051,7 @@ var StatusService = class {
|
|
|
1057
1051
|
* @param options - Health check options
|
|
1058
1052
|
* @returns Promise that resolves with the API health status
|
|
1059
1053
|
*/
|
|
1060
|
-
async
|
|
1054
|
+
async checkHealth(options) {
|
|
1061
1055
|
const { data, error } = await this.#api.GET("/health", {
|
|
1062
1056
|
params: { path: { version: "v1" } },
|
|
1063
1057
|
body: options ?? {}
|
|
@@ -1067,7 +1061,7 @@ var StatusService = class {
|
|
|
1067
1061
|
};
|
|
1068
1062
|
|
|
1069
1063
|
// src/services/webhooks.ts
|
|
1070
|
-
var
|
|
1064
|
+
var Webhooks = class {
|
|
1071
1065
|
#api;
|
|
1072
1066
|
constructor(api) {
|
|
1073
1067
|
this.#api = api;
|
|
@@ -1075,14 +1069,15 @@ var WebhooksService = class {
|
|
|
1075
1069
|
/**
|
|
1076
1070
|
* List all webhooks in a workspace
|
|
1077
1071
|
* @param workspaceId - Workspace ID
|
|
1078
|
-
* @
|
|
1072
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
1073
|
+
* @returns Promise that resolves with a paginated list of webhooks
|
|
1079
1074
|
* @throws {ApiError} if the request fails
|
|
1080
1075
|
*/
|
|
1081
|
-
async
|
|
1076
|
+
async listWebhooks(workspaceId, query) {
|
|
1082
1077
|
const { data } = await this.#api.GET(
|
|
1083
|
-
"/workspaces/{
|
|
1078
|
+
"/workspaces/{workspaceId}/webhooks/",
|
|
1084
1079
|
{
|
|
1085
|
-
params: { path: { workspaceId } }
|
|
1080
|
+
params: { path: { workspaceId }, query }
|
|
1086
1081
|
}
|
|
1087
1082
|
);
|
|
1088
1083
|
return data;
|
|
@@ -1093,8 +1088,8 @@ var WebhooksService = class {
|
|
|
1093
1088
|
* @returns Promise that resolves with the webhook details
|
|
1094
1089
|
* @throws {ApiError} if the request fails
|
|
1095
1090
|
*/
|
|
1096
|
-
async
|
|
1097
|
-
const { data } = await this.#api.GET("/webhooks/{
|
|
1091
|
+
async getWebhook(webhookId) {
|
|
1092
|
+
const { data } = await this.#api.GET("/webhooks/{webhookId}/", {
|
|
1098
1093
|
params: { path: { webhookId } }
|
|
1099
1094
|
});
|
|
1100
1095
|
return data;
|
|
@@ -1103,12 +1098,12 @@ var WebhooksService = class {
|
|
|
1103
1098
|
* Create a new webhook
|
|
1104
1099
|
* @param workspaceId - Workspace ID
|
|
1105
1100
|
* @param webhook - Webhook creation request
|
|
1106
|
-
* @returns Promise that resolves with the created webhook
|
|
1101
|
+
* @returns Promise that resolves with the created webhook
|
|
1107
1102
|
* @throws {ApiError} if the request fails
|
|
1108
1103
|
*/
|
|
1109
|
-
async
|
|
1104
|
+
async createWebhook(workspaceId, webhook) {
|
|
1110
1105
|
const { data } = await this.#api.POST(
|
|
1111
|
-
"/workspaces/{
|
|
1106
|
+
"/workspaces/{workspaceId}/webhooks/",
|
|
1112
1107
|
{
|
|
1113
1108
|
params: { path: { workspaceId } },
|
|
1114
1109
|
body: webhook
|
|
@@ -1123,8 +1118,8 @@ var WebhooksService = class {
|
|
|
1123
1118
|
* @returns Promise that resolves with the updated webhook
|
|
1124
1119
|
* @throws {ApiError} if the request fails
|
|
1125
1120
|
*/
|
|
1126
|
-
async
|
|
1127
|
-
const { data } = await this.#api.PUT("/webhooks/{
|
|
1121
|
+
async updateWebhook(webhookId, updates) {
|
|
1122
|
+
const { data } = await this.#api.PUT("/webhooks/{webhookId}/", {
|
|
1128
1123
|
params: { path: { webhookId } },
|
|
1129
1124
|
body: updates
|
|
1130
1125
|
});
|
|
@@ -1136,26 +1131,40 @@ var WebhooksService = class {
|
|
|
1136
1131
|
* @returns Promise that resolves when the webhook is deleted
|
|
1137
1132
|
* @throws {ApiError} if the request fails
|
|
1138
1133
|
*/
|
|
1139
|
-
async
|
|
1140
|
-
await this.#api.DELETE("/webhooks/{
|
|
1134
|
+
async deleteWebhook(webhookId) {
|
|
1135
|
+
await this.#api.DELETE("/webhooks/{webhookId}/", {
|
|
1141
1136
|
params: { path: { webhookId } }
|
|
1142
1137
|
});
|
|
1143
1138
|
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Test a webhook by sending a test payload
|
|
1141
|
+
* @param webhookId - Webhook ID
|
|
1142
|
+
* @param options - Test webhook options
|
|
1143
|
+
* @returns Promise that resolves with the test result
|
|
1144
|
+
* @throws {ApiError} if the request fails
|
|
1145
|
+
*/
|
|
1146
|
+
async testWebhook(webhookId, options) {
|
|
1147
|
+
const { data } = await this.#api.POST("/webhooks/{webhookId}/test/", {
|
|
1148
|
+
params: { path: { webhookId } },
|
|
1149
|
+
body: options ?? {}
|
|
1150
|
+
});
|
|
1151
|
+
return data;
|
|
1152
|
+
}
|
|
1144
1153
|
};
|
|
1145
1154
|
|
|
1146
1155
|
// src/services/workspaces.ts
|
|
1147
|
-
var
|
|
1156
|
+
var Workspaces = class {
|
|
1148
1157
|
#api;
|
|
1149
1158
|
constructor(api) {
|
|
1150
1159
|
this.#api = api;
|
|
1151
1160
|
}
|
|
1152
1161
|
/**
|
|
1153
1162
|
* List all workspaces
|
|
1154
|
-
* @param query - Optional
|
|
1155
|
-
* @returns Promise that resolves with
|
|
1163
|
+
* @param query - Optional pagination parameters (limit, after)
|
|
1164
|
+
* @returns Promise that resolves with a paginated list of workspaces
|
|
1156
1165
|
* @throws {ApiError} if the request fails
|
|
1157
1166
|
*/
|
|
1158
|
-
async
|
|
1167
|
+
async listWorkspaces(query) {
|
|
1159
1168
|
const { data } = await this.#api.GET("/workspaces/", {
|
|
1160
1169
|
params: { query }
|
|
1161
1170
|
});
|
|
@@ -1167,8 +1176,8 @@ var WorkspacesService = class {
|
|
|
1167
1176
|
* @returns Promise that resolves with the workspace details
|
|
1168
1177
|
* @throws {ApiError} if the request fails
|
|
1169
1178
|
*/
|
|
1170
|
-
async
|
|
1171
|
-
const { data } = await this.#api.GET("/workspaces/{
|
|
1179
|
+
async getWorkspace(workspaceId) {
|
|
1180
|
+
const { data } = await this.#api.GET("/workspaces/{workspaceId}/", {
|
|
1172
1181
|
params: { path: { workspaceId } }
|
|
1173
1182
|
});
|
|
1174
1183
|
return data;
|
|
@@ -1179,7 +1188,7 @@ var WorkspacesService = class {
|
|
|
1179
1188
|
* @returns Promise that resolves with the created workspace
|
|
1180
1189
|
* @throws {ApiError} if the request fails
|
|
1181
1190
|
*/
|
|
1182
|
-
async
|
|
1191
|
+
async createWorkspace(workspace) {
|
|
1183
1192
|
const { data } = await this.#api.POST("/workspaces/", {
|
|
1184
1193
|
body: workspace
|
|
1185
1194
|
});
|
|
@@ -1192,8 +1201,8 @@ var WorkspacesService = class {
|
|
|
1192
1201
|
* @returns Promise that resolves with the updated workspace
|
|
1193
1202
|
* @throws {ApiError} if the request fails
|
|
1194
1203
|
*/
|
|
1195
|
-
async
|
|
1196
|
-
const { data } = await this.#api.PATCH("/workspaces/{
|
|
1204
|
+
async updateWorkspace(workspaceId, updates) {
|
|
1205
|
+
const { data } = await this.#api.PATCH("/workspaces/{workspaceId}/", {
|
|
1197
1206
|
params: { path: { workspaceId } },
|
|
1198
1207
|
body: updates
|
|
1199
1208
|
});
|
|
@@ -1205,15 +1214,47 @@ var WorkspacesService = class {
|
|
|
1205
1214
|
* @returns Promise that resolves when the workspace is deleted
|
|
1206
1215
|
* @throws {ApiError} if the request fails
|
|
1207
1216
|
*/
|
|
1208
|
-
async
|
|
1209
|
-
await this.#api.DELETE("/workspaces/{
|
|
1217
|
+
async deleteWorkspace(workspaceId) {
|
|
1218
|
+
await this.#api.DELETE("/workspaces/{workspaceId}/", {
|
|
1210
1219
|
params: { path: { workspaceId } }
|
|
1211
1220
|
});
|
|
1212
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Get notification settings for the authenticated user in a workspace
|
|
1224
|
+
* @param workspaceId - Workspace ID
|
|
1225
|
+
* @returns Promise that resolves with the notification settings
|
|
1226
|
+
* @throws {ApiError} if the request fails
|
|
1227
|
+
*/
|
|
1228
|
+
async getNotificationSettings(workspaceId) {
|
|
1229
|
+
const { data } = await this.#api.GET(
|
|
1230
|
+
"/workspaces/{workspaceId}/notifications",
|
|
1231
|
+
{
|
|
1232
|
+
params: { path: { workspaceId } }
|
|
1233
|
+
}
|
|
1234
|
+
);
|
|
1235
|
+
return data;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Update notification settings for the authenticated user in a workspace
|
|
1239
|
+
* @param workspaceId - Workspace ID
|
|
1240
|
+
* @param settings - Notification settings update request
|
|
1241
|
+
* @returns Promise that resolves with the updated notification settings
|
|
1242
|
+
* @throws {ApiError} if the request fails
|
|
1243
|
+
*/
|
|
1244
|
+
async updateNotificationSettings(workspaceId, settings) {
|
|
1245
|
+
const { data } = await this.#api.PATCH(
|
|
1246
|
+
"/workspaces/{workspaceId}/notifications",
|
|
1247
|
+
{
|
|
1248
|
+
params: { path: { workspaceId } },
|
|
1249
|
+
body: settings
|
|
1250
|
+
}
|
|
1251
|
+
);
|
|
1252
|
+
return data;
|
|
1253
|
+
}
|
|
1213
1254
|
};
|
|
1214
1255
|
|
|
1215
1256
|
// src/client.ts
|
|
1216
|
-
var
|
|
1257
|
+
var Nvisy = class _Nvisy {
|
|
1217
1258
|
/**
|
|
1218
1259
|
* The resolved client configuration with defaults applied.
|
|
1219
1260
|
* @internal
|
|
@@ -1228,15 +1269,15 @@ var Client = class _Client {
|
|
|
1228
1269
|
* Creates a new Nvisy client instance.
|
|
1229
1270
|
*
|
|
1230
1271
|
* @param config - Configuration options with required `apiToken`
|
|
1231
|
-
* @throws {
|
|
1272
|
+
* @throws {NvisyError} If the API token is invalid
|
|
1232
1273
|
*
|
|
1233
1274
|
* @example
|
|
1234
1275
|
* ```typescript
|
|
1235
|
-
* const
|
|
1276
|
+
* const nvisy = new Nvisy({
|
|
1236
1277
|
* apiToken: "your-api-token",
|
|
1237
1278
|
* baseUrl: "https://custom.api.nvisy.com",
|
|
1238
1279
|
* });
|
|
1239
|
-
* const account = await
|
|
1280
|
+
* const account = await nvisy.account.getAccount();
|
|
1240
1281
|
* ```
|
|
1241
1282
|
*/
|
|
1242
1283
|
constructor(config) {
|
|
@@ -1245,7 +1286,8 @@ var Client = class _Client {
|
|
|
1245
1286
|
apiToken: validatedToken,
|
|
1246
1287
|
baseUrl: config.baseUrl ?? DEFAULTS.BASE_URL,
|
|
1247
1288
|
headers: config.headers ?? {},
|
|
1248
|
-
userAgent: config.userAgent ?? DEFAULTS.USER_AGENT
|
|
1289
|
+
userAgent: config.userAgent ?? DEFAULTS.USER_AGENT,
|
|
1290
|
+
withLogging: config.withLogging ?? false
|
|
1249
1291
|
};
|
|
1250
1292
|
this.#api = this.#createApiClient();
|
|
1251
1293
|
}
|
|
@@ -1266,6 +1308,9 @@ var Client = class _Client {
|
|
|
1266
1308
|
baseUrl: this.#config.baseUrl,
|
|
1267
1309
|
headers
|
|
1268
1310
|
});
|
|
1311
|
+
if (this.#config.withLogging) {
|
|
1312
|
+
api.use(createLoggingMiddleware());
|
|
1313
|
+
}
|
|
1269
1314
|
api.use(errorMiddleware);
|
|
1270
1315
|
return api;
|
|
1271
1316
|
}
|
|
@@ -1274,22 +1319,19 @@ var Client = class _Client {
|
|
|
1274
1319
|
*
|
|
1275
1320
|
* @param apiToken - The API token to validate
|
|
1276
1321
|
* @returns The trimmed API token if valid
|
|
1277
|
-
* @throws {
|
|
1322
|
+
* @throws {NvisyError} If the API token is invalid
|
|
1278
1323
|
* @internal
|
|
1279
1324
|
*/
|
|
1280
1325
|
#validateApiToken(apiToken) {
|
|
1281
1326
|
if (typeof apiToken !== "string" || apiToken.trim().length === 0) {
|
|
1282
|
-
throw
|
|
1327
|
+
throw new NvisyError("API token must be a non-empty string");
|
|
1283
1328
|
}
|
|
1284
1329
|
const trimmedToken = apiToken.trim();
|
|
1285
1330
|
if (trimmedToken.length < 10) {
|
|
1286
|
-
throw
|
|
1287
|
-
"apiToken",
|
|
1288
|
-
"must be at least 10 characters"
|
|
1289
|
-
);
|
|
1331
|
+
throw new NvisyError("API token must be at least 10 characters");
|
|
1290
1332
|
}
|
|
1291
|
-
if (!/^[a-zA-Z0-9_
|
|
1292
|
-
throw
|
|
1333
|
+
if (!/^[a-zA-Z0-9_.\-]+$/.test(trimmedToken)) {
|
|
1334
|
+
throw new NvisyError("API token contains invalid characters");
|
|
1293
1335
|
}
|
|
1294
1336
|
return trimmedToken;
|
|
1295
1337
|
}
|
|
@@ -1301,20 +1343,20 @@ var Client = class _Client {
|
|
|
1301
1343
|
* is preserved in the new client.
|
|
1302
1344
|
*
|
|
1303
1345
|
* @param apiToken - The new API token
|
|
1304
|
-
* @returns A new
|
|
1305
|
-
* @throws {
|
|
1346
|
+
* @returns A new Nvisy instance with the new token
|
|
1347
|
+
* @throws {NvisyError} If the API token is invalid
|
|
1306
1348
|
*
|
|
1307
1349
|
* @example
|
|
1308
1350
|
* ```typescript
|
|
1309
|
-
* const
|
|
1310
|
-
* const
|
|
1351
|
+
* const nvisy = new Nvisy({ apiToken: "original-token" });
|
|
1352
|
+
* const newNvisy = nvisy.withApiToken("new-token");
|
|
1311
1353
|
*
|
|
1312
|
-
* //
|
|
1313
|
-
* //
|
|
1354
|
+
* // newNvisy uses the new token
|
|
1355
|
+
* // nvisy still uses the original token
|
|
1314
1356
|
* ```
|
|
1315
1357
|
*/
|
|
1316
1358
|
withApiToken(apiToken) {
|
|
1317
|
-
return new
|
|
1359
|
+
return new _Nvisy({ ...this.#config, apiToken });
|
|
1318
1360
|
}
|
|
1319
1361
|
/**
|
|
1320
1362
|
* The base URL used for API requests.
|
|
@@ -1337,102 +1379,102 @@ var Client = class _Client {
|
|
|
1337
1379
|
}
|
|
1338
1380
|
/**
|
|
1339
1381
|
* Service for authentication operations (login, signup, logout).
|
|
1340
|
-
*
|
|
1341
|
-
* @returns The AuthService instance
|
|
1342
1382
|
*/
|
|
1343
1383
|
get auth() {
|
|
1344
|
-
return new
|
|
1384
|
+
return new Auth(this.#api);
|
|
1345
1385
|
}
|
|
1346
1386
|
/**
|
|
1347
1387
|
* Service for API status and health checks.
|
|
1348
|
-
*
|
|
1349
|
-
* @returns The StatusService instance
|
|
1350
1388
|
*/
|
|
1351
1389
|
get status() {
|
|
1352
|
-
return new
|
|
1390
|
+
return new Status(this.#api);
|
|
1353
1391
|
}
|
|
1354
1392
|
/**
|
|
1355
1393
|
* Service for managing the authenticated user's account.
|
|
1356
|
-
*
|
|
1357
|
-
* @returns The AccountService instance
|
|
1358
1394
|
*/
|
|
1359
1395
|
get account() {
|
|
1360
|
-
return new
|
|
1396
|
+
return new Account(this.#api);
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Service for viewing workspace activities.
|
|
1400
|
+
*/
|
|
1401
|
+
get activities() {
|
|
1402
|
+
return new Activities(this.#api);
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Service for managing file annotations.
|
|
1406
|
+
*/
|
|
1407
|
+
get annotations() {
|
|
1408
|
+
return new Annotations(this.#api);
|
|
1361
1409
|
}
|
|
1362
1410
|
/**
|
|
1363
1411
|
* Service for managing API tokens.
|
|
1364
|
-
*
|
|
1365
|
-
* @returns The ApiTokensService instance
|
|
1366
1412
|
*/
|
|
1367
1413
|
get apiTokens() {
|
|
1368
|
-
return new
|
|
1414
|
+
return new ApiTokens(this.#api);
|
|
1369
1415
|
}
|
|
1370
1416
|
/**
|
|
1371
1417
|
* Service for managing file comments.
|
|
1372
|
-
*
|
|
1373
|
-
* @returns The CommentsService instance
|
|
1374
1418
|
*/
|
|
1375
1419
|
get comments() {
|
|
1376
|
-
return new
|
|
1420
|
+
return new Comments(this.#api);
|
|
1377
1421
|
}
|
|
1378
1422
|
/**
|
|
1379
1423
|
* Service for document operations.
|
|
1380
|
-
*
|
|
1381
|
-
* @returns The DocumentsService instance
|
|
1382
1424
|
*/
|
|
1383
1425
|
get documents() {
|
|
1384
|
-
return new
|
|
1426
|
+
return new Documents(this.#api);
|
|
1385
1427
|
}
|
|
1386
1428
|
/**
|
|
1387
1429
|
* Service for file operations (upload, download, delete).
|
|
1388
|
-
*
|
|
1389
|
-
* @returns The FilesService instance
|
|
1390
1430
|
*/
|
|
1391
1431
|
get files() {
|
|
1392
|
-
return new
|
|
1432
|
+
return new Files(this.#api);
|
|
1393
1433
|
}
|
|
1394
1434
|
/**
|
|
1395
1435
|
* Service for managing integrations.
|
|
1396
|
-
*
|
|
1397
|
-
* @returns The IntegrationsService instance
|
|
1398
1436
|
*/
|
|
1399
1437
|
get integrations() {
|
|
1400
|
-
return new
|
|
1438
|
+
return new Integrations(this.#api);
|
|
1401
1439
|
}
|
|
1402
1440
|
/**
|
|
1403
1441
|
* Service for managing workspace invitations.
|
|
1404
|
-
*
|
|
1405
|
-
* @returns The InvitesService instance
|
|
1406
1442
|
*/
|
|
1407
1443
|
get invites() {
|
|
1408
|
-
return new
|
|
1444
|
+
return new Invites(this.#api);
|
|
1409
1445
|
}
|
|
1410
1446
|
/**
|
|
1411
1447
|
* Service for managing workspace members.
|
|
1412
|
-
*
|
|
1413
|
-
* @returns The MembersService instance
|
|
1414
1448
|
*/
|
|
1415
1449
|
get members() {
|
|
1416
|
-
return new
|
|
1450
|
+
return new Members(this.#api);
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Service for managing notifications.
|
|
1454
|
+
*/
|
|
1455
|
+
get notifications() {
|
|
1456
|
+
return new Notifications(this.#api);
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Service for managing processing runs.
|
|
1460
|
+
*/
|
|
1461
|
+
get runs() {
|
|
1462
|
+
return new Runs(this.#api);
|
|
1417
1463
|
}
|
|
1418
1464
|
/**
|
|
1419
1465
|
* Service for managing webhooks.
|
|
1420
|
-
*
|
|
1421
|
-
* @returns The WebhooksService instance
|
|
1422
1466
|
*/
|
|
1423
1467
|
get webhooks() {
|
|
1424
|
-
return new
|
|
1468
|
+
return new Webhooks(this.#api);
|
|
1425
1469
|
}
|
|
1426
1470
|
/**
|
|
1427
1471
|
* Service for managing workspaces.
|
|
1428
|
-
*
|
|
1429
|
-
* @returns The WorkspacesService instance
|
|
1430
1472
|
*/
|
|
1431
1473
|
get workspaces() {
|
|
1432
|
-
return new
|
|
1474
|
+
return new Workspaces(this.#api);
|
|
1433
1475
|
}
|
|
1434
1476
|
};
|
|
1435
1477
|
|
|
1436
|
-
export {
|
|
1478
|
+
export { DEFAULTS, Nvisy, NvisyApiError, NvisyError, VERSION };
|
|
1437
1479
|
//# sourceMappingURL=index.js.map
|
|
1438
1480
|
//# sourceMappingURL=index.js.map
|