@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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Configuration types and constants for the Nvisy SDK.
|
|
3
|
+
*
|
|
4
|
+
* This module provides configuration interfaces, default values, and environment
|
|
5
|
+
* variable names used throughout the SDK.
|
|
6
|
+
*
|
|
7
|
+
* @module config
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Current SDK version.
|
|
11
|
+
*
|
|
12
|
+
* Used in the default user agent string and for version tracking.
|
|
13
|
+
*/
|
|
14
|
+
declare const VERSION = "0.3.0";
|
|
15
|
+
/**
|
|
16
|
+
* Configuration options for creating a Nvisy client.
|
|
17
|
+
*
|
|
18
|
+
* The `apiToken` field is required for authentication. All other fields are optional
|
|
19
|
+
* and will use sensible defaults when omitted.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const config: ClientConfig = {
|
|
24
|
+
* apiToken: "your-api-token",
|
|
25
|
+
* baseUrl: "https://api.nvisy.com",
|
|
26
|
+
* headers: { "X-Custom-Header": "value" },
|
|
27
|
+
* };
|
|
28
|
+
* const client = new Client(config);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
interface ClientConfig {
|
|
32
|
+
/**
|
|
33
|
+
* API token for authentication.
|
|
34
|
+
*
|
|
35
|
+
* Tokens can be obtained from the Nvisy dashboard or via the auth endpoints.
|
|
36
|
+
*/
|
|
37
|
+
apiToken: string;
|
|
38
|
+
/**
|
|
39
|
+
* Base URL for the Nvisy API.
|
|
40
|
+
*
|
|
41
|
+
* @default "https://api.nvisy.com"
|
|
42
|
+
*/
|
|
43
|
+
baseUrl?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Custom headers to include with every request.
|
|
46
|
+
*
|
|
47
|
+
* These headers are merged with the default headers (Content-Type, User-Agent,
|
|
48
|
+
* and Authorization). Custom headers take precedence over defaults if there
|
|
49
|
+
* are conflicts.
|
|
50
|
+
*/
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
/**
|
|
53
|
+
* Custom user agent string to identify your application.
|
|
54
|
+
*
|
|
55
|
+
* @default "@nvisy/sdk v.{version}"
|
|
56
|
+
*/
|
|
57
|
+
userAgent?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Enable logging for requests and responses.
|
|
60
|
+
*
|
|
61
|
+
* When enabled, logs request method, URL, status, and timing to console.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
withLogging?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Default configuration values used when options are not explicitly provided.
|
|
69
|
+
*/
|
|
70
|
+
declare const DEFAULTS: {
|
|
71
|
+
/**
|
|
72
|
+
* Default base URL for the Nvisy API.
|
|
73
|
+
*/
|
|
74
|
+
readonly BASE_URL: "https://api.nvisy.com";
|
|
75
|
+
/**
|
|
76
|
+
* Default user agent string.
|
|
77
|
+
*/
|
|
78
|
+
readonly USER_AGENT: "@nvisy/sdk v.0.3.0";
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { type ClientConfig as C, DEFAULTS as D, VERSION as V };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { A as Account, c as ActivitiesPage, a as Activity, b as ActivityType, d as Annotation, f as AnnotationsPage, g as ApiToken, i as ApiTokenType, h as ApiTokenWithJWT, l as ApiTokensPage, x as ArchiveFormat, af as CheckHealth, m as Comment, p as CommentsPage, u as ContentSegmentation, C as CreateAnnotation, j as CreateApiToken, n as CreateComment, q as CreateDocument, B as CreateIntegration, N as CreateInvite, ah as CreateWebhook, ap as CreateWorkspace, aa as CursorPagination, w as DeleteFiles, D as Document, s as DocumentsPage, v as DownloadFiles, F as File, y as FileFormat, z as FilesPage, O as GenerateInviteCode, I as Integration, ab as IntegrationRun, ac as IntegrationRunsPage, J as IntegrationStatus, H as IntegrationType, K as IntegrationsPage, M as Invite, Q as InviteCode, V as InviteExpiration, Z as InvitePreview, X as InviteSortField, S as InviteStatus, _ as InvitesPage, L as ListFiles, W as ListInvites, a1 as ListMembers, $ as Member, a2 as MemberSortField, a3 as MembersPage, ad as MonitorStatus, a4 as Notification, a5 as NotificationEvent, a6 as NotificationSettings, a9 as NotificationsPage, P as ProcessingStatus, R as ReplyInvite, ae as ServiceStatus, Y as SortOrder, aj as TestWebhook, T as TokenExpiration, a8 as UnreadStatus, U as UpdateAccount, e as UpdateAnnotation, k as UpdateApiToken, o as UpdateComment, r as UpdateDocument, t as UpdateFile, E as UpdateIntegration, G as UpdateIntegrationCredentials, a0 as UpdateMember, a7 as UpdateNotificationSettings, ai as UpdateWebhook, aq as UpdateWorkspace, ag as Webhook, am as WebhookEvent, ak as WebhookResult, al as WebhookStatus, an as WebhooksPage, ao as Workspace, ar as WorkspaceRole, as as WorkspacesPage } from '../workspace-BjdbMWsa.js';
|
|
2
|
+
import { c as components } from '../auth-CncOz2vx.js';
|
|
3
|
+
export { A as AuthToken, L as Login, S as Signup } from '../auth-CncOz2vx.js';
|
|
3
4
|
|
|
4
5
|
type Schemas = components["schemas"];
|
|
5
6
|
type ErrorResponse = Schemas["ErrorResponse"];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,49 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { A as ApiClient, N as Nvisy } from './client-DQRisDAK.js';
|
|
2
|
+
export { C as ClientConfig, D as DEFAULTS, V as VERSION } from './config-L7FKq_q5.js';
|
|
3
3
|
import { ErrorResponse } from './datatypes/index.js';
|
|
4
|
-
export { ValidationErrorDetail } from './datatypes/index.js';
|
|
5
4
|
import 'openapi-fetch';
|
|
5
|
+
import './auth-CncOz2vx.js';
|
|
6
|
+
import './workspace-BjdbMWsa.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @fileoverview Error types for the Nvisy SDK.
|
|
9
10
|
*
|
|
10
11
|
* This module defines the error hierarchy used throughout the SDK:
|
|
11
|
-
* - {@link
|
|
12
|
-
* - {@link
|
|
13
|
-
* - {@link NetworkError} - Network connectivity and request failures
|
|
14
|
-
*
|
|
15
|
-
* All errors extend the built-in Error class and include additional context
|
|
16
|
-
* to help with debugging and error handling.
|
|
12
|
+
* - {@link NvisyError} - Base error class for all SDK errors
|
|
13
|
+
* - {@link NvisyApiError} - Errors returned by the Nvisy API (4xx/5xx responses)
|
|
17
14
|
*
|
|
18
15
|
* @module errors
|
|
19
16
|
*/
|
|
20
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Base error class for all Nvisy SDK errors.
|
|
20
|
+
*
|
|
21
|
+
* This class provides common functionality for all SDK errors.
|
|
22
|
+
* It ensures proper error naming and stack traces.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* try {
|
|
27
|
+
* const client = new Client({ apiToken: "" });
|
|
28
|
+
* } catch (error) {
|
|
29
|
+
* if (error instanceof NvisyError) {
|
|
30
|
+
* console.log("SDK error:", error.message);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare class NvisyError extends Error {
|
|
36
|
+
/**
|
|
37
|
+
* The error class name.
|
|
38
|
+
*/
|
|
39
|
+
readonly name: string;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new NvisyError.
|
|
42
|
+
*
|
|
43
|
+
* @param message - The error message
|
|
44
|
+
*/
|
|
45
|
+
constructor(message: string);
|
|
46
|
+
}
|
|
21
47
|
/**
|
|
22
48
|
* Error thrown when the Nvisy API returns an error response.
|
|
23
49
|
*
|
|
@@ -28,9 +54,9 @@ import 'openapi-fetch';
|
|
|
28
54
|
* @example
|
|
29
55
|
* ```typescript
|
|
30
56
|
* try {
|
|
31
|
-
* await client.account.
|
|
57
|
+
* await client.account.getAccount();
|
|
32
58
|
* } catch (error) {
|
|
33
|
-
* if (error instanceof
|
|
59
|
+
* if (error instanceof NvisyApiError) {
|
|
34
60
|
* console.log(`API Error: ${error.message}`);
|
|
35
61
|
* console.log(`Status: ${error.statusCode}`);
|
|
36
62
|
* if (error.isRetryable()) {
|
|
@@ -40,7 +66,7 @@ import 'openapi-fetch';
|
|
|
40
66
|
* }
|
|
41
67
|
* ```
|
|
42
68
|
*/
|
|
43
|
-
declare class
|
|
69
|
+
declare class NvisyApiError extends NvisyError implements ErrorResponse {
|
|
44
70
|
/**
|
|
45
71
|
* The error type identifier (e.g., "ValidationError", "NotFoundError").
|
|
46
72
|
*/
|
|
@@ -63,13 +89,13 @@ declare class ApiError extends Error implements ErrorResponse {
|
|
|
63
89
|
* Field-specific validation errors.
|
|
64
90
|
* Present when the error is due to invalid input data.
|
|
65
91
|
*/
|
|
66
|
-
readonly
|
|
92
|
+
readonly validation?: ErrorResponse["validation"];
|
|
67
93
|
/**
|
|
68
94
|
* HTTP status code of the response (e.g., 400, 404, 500).
|
|
69
95
|
*/
|
|
70
96
|
readonly statusCode: number;
|
|
71
97
|
/**
|
|
72
|
-
* Creates a new
|
|
98
|
+
* Creates a new NvisyApiError from an API error response.
|
|
73
99
|
*
|
|
74
100
|
* @param response - The error response from the API
|
|
75
101
|
* @param statusCode - The HTTP status code of the response
|
|
@@ -111,145 +137,5 @@ declare class ApiError extends Error implements ErrorResponse {
|
|
|
111
137
|
*/
|
|
112
138
|
toJSON(): ErrorResponse;
|
|
113
139
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Abstract base class for SDK-specific errors.
|
|
116
|
-
*
|
|
117
|
-
* This class provides common functionality for all client-side errors
|
|
118
|
-
* (as opposed to API errors). It ensures proper error naming and stack traces.
|
|
119
|
-
*
|
|
120
|
-
* @internal
|
|
121
|
-
*/
|
|
122
|
-
declare abstract class ClientError extends Error {
|
|
123
|
-
/**
|
|
124
|
-
* The error class name (e.g., "ConfigError", "NetworkError").
|
|
125
|
-
*/
|
|
126
|
-
readonly name: string;
|
|
127
|
-
/**
|
|
128
|
-
* Creates a new ClientError.
|
|
129
|
-
*
|
|
130
|
-
* @param message - The error message
|
|
131
|
-
*/
|
|
132
|
-
constructor(message: string);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Error thrown when client configuration is invalid.
|
|
136
|
-
*
|
|
137
|
-
* This error is thrown during client initialization if the provided
|
|
138
|
-
* configuration is missing required fields or contains invalid values.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```typescript
|
|
142
|
-
* try {
|
|
143
|
-
* const client = new Client().withApiToken("short");
|
|
144
|
-
* } catch (error) {
|
|
145
|
-
* if (error instanceof ConfigError) {
|
|
146
|
-
* console.log(`Config error in field '${error.field}': ${error.reason}`);
|
|
147
|
-
* }
|
|
148
|
-
* }
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
declare class ConfigError extends ClientError {
|
|
152
|
-
/**
|
|
153
|
-
* The configuration field that caused the error.
|
|
154
|
-
* May be undefined for general configuration errors.
|
|
155
|
-
*/
|
|
156
|
-
readonly field?: string;
|
|
157
|
-
/**
|
|
158
|
-
* A description of why the configuration is invalid.
|
|
159
|
-
* May be undefined for simple errors.
|
|
160
|
-
*/
|
|
161
|
-
readonly reason?: string;
|
|
162
|
-
/**
|
|
163
|
-
* Creates a new ConfigError.
|
|
164
|
-
*
|
|
165
|
-
* @param message - The error message
|
|
166
|
-
* @param options - Additional error context
|
|
167
|
-
* @param options.field - The field that caused the error
|
|
168
|
-
* @param options.reason - Why the configuration is invalid
|
|
169
|
-
*/
|
|
170
|
-
constructor(message: string, options?: {
|
|
171
|
-
field?: string;
|
|
172
|
-
reason?: string;
|
|
173
|
-
});
|
|
174
|
-
/**
|
|
175
|
-
* Creates a ConfigError for a missing API token.
|
|
176
|
-
*
|
|
177
|
-
* @returns A ConfigError indicating the API token is required
|
|
178
|
-
*
|
|
179
|
-
* @internal
|
|
180
|
-
*/
|
|
181
|
-
static missingApiToken(): ConfigError;
|
|
182
|
-
/**
|
|
183
|
-
* Creates a ConfigError for an invalid configuration field.
|
|
184
|
-
*
|
|
185
|
-
* @param field - The name of the invalid field
|
|
186
|
-
* @param reason - Why the field value is invalid
|
|
187
|
-
* @returns A ConfigError with field and reason context
|
|
188
|
-
*
|
|
189
|
-
* @internal
|
|
190
|
-
*/
|
|
191
|
-
static invalidField(field: string, reason: string): ConfigError;
|
|
192
|
-
/**
|
|
193
|
-
* Creates a ConfigError for a missing required field.
|
|
194
|
-
*
|
|
195
|
-
* @param field - The name of the missing field
|
|
196
|
-
* @returns A ConfigError indicating the field is required
|
|
197
|
-
*
|
|
198
|
-
* @internal
|
|
199
|
-
*/
|
|
200
|
-
static missingField(field: string): ConfigError;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Error thrown when a network request fails.
|
|
204
|
-
*
|
|
205
|
-
* This error wraps underlying network errors (connection failures, timeouts,
|
|
206
|
-
* aborted requests) and provides a consistent interface for handling them.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```typescript
|
|
210
|
-
* try {
|
|
211
|
-
* await client.account.get();
|
|
212
|
-
* } catch (error) {
|
|
213
|
-
* if (error instanceof NetworkError) {
|
|
214
|
-
* console.log("Network error:", error.message);
|
|
215
|
-
* if (error.cause) {
|
|
216
|
-
* console.log("Caused by:", error.cause.message);
|
|
217
|
-
* }
|
|
218
|
-
* }
|
|
219
|
-
* }
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
declare class NetworkError extends ClientError {
|
|
223
|
-
/**
|
|
224
|
-
* The underlying error that caused this network error.
|
|
225
|
-
* May be undefined if no underlying error is available.
|
|
226
|
-
*/
|
|
227
|
-
readonly cause?: Error;
|
|
228
|
-
/**
|
|
229
|
-
* Creates a new NetworkError.
|
|
230
|
-
*
|
|
231
|
-
* @param message - The error message
|
|
232
|
-
* @param cause - The underlying error that caused this failure
|
|
233
|
-
*/
|
|
234
|
-
constructor(message: string, cause?: Error);
|
|
235
|
-
/**
|
|
236
|
-
* Creates a NetworkError for connection issues.
|
|
237
|
-
*
|
|
238
|
-
* @param message - Description of the connection problem
|
|
239
|
-
* @param cause - The underlying error
|
|
240
|
-
* @returns A NetworkError for connection failures
|
|
241
|
-
*
|
|
242
|
-
* @internal
|
|
243
|
-
*/
|
|
244
|
-
static connection(message: string, cause?: Error): NetworkError;
|
|
245
|
-
/**
|
|
246
|
-
* Creates a NetworkError for aborted requests.
|
|
247
|
-
*
|
|
248
|
-
* @returns A NetworkError indicating the request was aborted
|
|
249
|
-
*
|
|
250
|
-
* @internal
|
|
251
|
-
*/
|
|
252
|
-
static aborted(): NetworkError;
|
|
253
|
-
}
|
|
254
140
|
|
|
255
|
-
export {
|
|
141
|
+
export { ErrorResponse, NvisyApiError, NvisyError };
|