@nvisy/sdk 0.3.0 → 0.4.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 CHANGED
@@ -8,6 +8,38 @@ and this project adheres to
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.4.0] - 2026-07-12
12
+
13
+ ### Added
14
+
15
+ - `contexts` service and datatypes (`Context`, `CreateContext`,
16
+ `UpdateContext`, `ContextEntry`, `ContextsPage`)
17
+ - `connections` service and datatypes (`Connection`, `CreateConnection`,
18
+ `UpdateConnection`, `ConnectionsQuery`, `ConnectionsPage`)
19
+ - `pipelines` service and datatypes (`Pipeline`, `CreatePipeline`,
20
+ `UpdatePipeline`, `PipelineDefinition`, `PipelineStatus`, `PipelineSummary`,
21
+ `PipelineSummariesPage`, and more)
22
+ - `policies` service and datatypes (`Policy`, `CreatePolicy`, `UpdatePolicy`,
23
+ `PolicyRule`, `PolicyAction`, `PoliciesPage`)
24
+ - `Health` datatypes for the health endpoint (`Health`, `HealthStatus`,
25
+ `ComponentHealth`, `CheckHealth`)
26
+
27
+ ### Changed
28
+
29
+ - Regenerated the API schema against the redacted-pipeline platform API
30
+ - **BREAKING**: `runs` is now a pipeline-run service: `listRuns(pipelineId)`,
31
+ `createRun(pipelineId)`, `getRun(runId)`, `getDetections(runId)`,
32
+ `redact(runId)` (was integration-run based)
33
+ - **BREAKING**: `status.checkHealth()` now returns `Health` (was
34
+ `MonitorStatus`)
35
+ - **BREAKING**: `NvisyApiError.resource` and `.suggestion` are now
36
+ `string | undefined` (were `string | null`)
37
+
38
+ ### Removed
39
+
40
+ - **BREAKING**: `annotations`, `comments`, `documents`, and `integrations`
41
+ services and their datatypes (no longer part of the API)
42
+
11
43
  ## [0.3.0] - 2026-01-09
12
44
 
13
45
  ### Added
@@ -107,7 +139,8 @@ and this project adheres to
107
139
  - Network error handling for timeouts, DNS resolution, and connection issues
108
140
  - Configuration validation with detailed error messages
109
141
 
110
- [Unreleased]: https://github.com/nvisycom/sdk-ts/compare/v0.3.0...HEAD
142
+ [Unreleased]: https://github.com/nvisycom/sdk-ts/compare/v0.4.0...HEAD
143
+ [0.4.0]: https://github.com/nvisycom/sdk-ts/compare/v0.3.0...v0.4.0
111
144
  [0.3.0]: https://github.com/nvisycom/sdk-ts/compare/v0.2.0...v0.3.0
112
145
  [0.2.0]: https://github.com/nvisycom/sdk-ts/compare/v0.1.0...v0.2.0
113
146
  [0.1.0]: https://github.com/nvisycom/sdk-ts/releases/tag/v0.1.0
package/README.md CHANGED
@@ -1,16 +1,20 @@
1
- # Nvisy.com SDK for TypeScript/JavaScript
1
+ # Nvisy SDK for TypeScript
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@nvisy/sdk?color=000000&style=flat-square)](https://www.npmjs.com/package/@nvisy/sdk)
4
- [![build](https://img.shields.io/github/actions/workflow/status/nvisycom/sdk-ts/build.yml?branch=main&color=000000&style=flat-square)](https://github.com/nvisycom/sdk-ts/actions/workflows/build.yml)
3
+ [![npm](https://img.shields.io/npm/v/@nvisy/sdk?style=flat-square)](https://www.npmjs.com/package/@nvisy/sdk)
4
+ [![Build](https://img.shields.io/github/actions/workflow/status/nvisycom/sdk-ts/build.yml?branch=main&label=build%20%26%20test&style=flat-square)](https://github.com/nvisycom/sdk-ts/actions/workflows/build.yml)
5
5
 
6
- Official TypeScript SDK for the Nvisy AI-powered document processing platform.
6
+ TypeScript client for the [Nvisy](https://nvisy.com/) multimodal redaction platform.
7
7
 
8
- ## Features
8
+ Nvisy detects and removes sensitive information across documents, images, and audio.
9
+ It combines deterministic patterns, NER, computer vision, and LLM-driven classification
10
+ into auditable, policy-driven pipelines built for regulated industries such as
11
+ healthcare, legal, government, and financial services.
9
12
 
10
- - Modern ES2022+ JavaScript target
11
- - Full TypeScript support with strict typing
12
- - Debug logging for development
13
- - Individual module exports for optimal bundling
13
+ > [!WARNING]
14
+ > **Active development: API not stable.** This project is under active
15
+ > development. Public APIs, configuration shapes, and on-disk formats may change
16
+ > without notice between releases. Pin a specific version if you depend on this
17
+ > in production.
14
18
 
15
19
  ## Installation
16
20
 
@@ -18,12 +22,21 @@ Official TypeScript SDK for the Nvisy AI-powered document processing platform.
18
22
  npm install @nvisy/sdk
19
23
  ```
20
24
 
21
- ## Usage
25
+ ## Quick Start
22
26
 
23
27
  ```typescript
24
28
  import { Nvisy } from "@nvisy/sdk";
25
29
 
26
- const nvisy = new Nvisy({
30
+ const client = new Nvisy({ apiToken: "your-api-token" });
31
+
32
+ const account = await client.account.getAccount();
33
+ const workspaces = await client.workspaces.listWorkspaces();
34
+ ```
35
+
36
+ The client accepts additional options:
37
+
38
+ ```typescript
39
+ const client = new Nvisy({
27
40
  apiToken: "your-api-token", // Required
28
41
  baseUrl: "https://api.nvisy.com", // Optional
29
42
  userAgent: "MyApp/1.0.0", // Optional
@@ -32,25 +45,35 @@ const nvisy = new Nvisy({
32
45
  "X-Custom-Header": "value",
33
46
  },
34
47
  });
35
-
36
- const account = await nvisy.account.getAccount();
37
- const workspaces = await nvisy.workspaces.listWorkspaces();
38
48
  ```
39
49
 
40
- ## Changelog
50
+ ## Features
41
51
 
42
- See [CHANGELOG.md](CHANGELOG.md) for release notes and version history.
52
+ - Modern ES2022+ JavaScript target
53
+ - Full TypeScript support with strict typing
54
+ - Debug logging for development
55
+ - Individual module exports for optimal bundling
56
+
57
+ ## Deployment
58
+
59
+ The fastest way to get started is with [Nvisy Cloud](https://nvisy.com).
60
+
61
+ To run locally, see the [nvisycom/runtime](https://github.com/nvisycom/runtime) and [nvisycom/server](https://github.com/nvisycom/server) repositories.
43
62
 
44
63
  ## Contributing
45
64
 
46
- See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines.
65
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and contribution guidelines.
66
+
67
+ ## Changelog
68
+
69
+ See [CHANGELOG.md](CHANGELOG.md) for release notes and version history.
47
70
 
48
71
  ## License
49
72
 
50
- MIT License - see [LICENSE.txt](LICENSE.txt) for details.
73
+ MIT License, see [LICENSE.txt](LICENSE.txt)
51
74
 
52
75
  ## Support
53
76
 
54
- - Documentation: [docs.nvisy.com](https://docs.nvisy.com)
55
- - Issues: [GitHub Issues](https://github.com/nvisycom/sdk-ts/issues)
56
- - Email: [support@nvisy.com](mailto:support@nvisy.com)
77
+ - **Documentation**: [docs.nvisy.com](https://docs.nvisy.com)
78
+ - **Issues**: [github.com/nvisycom/sdk-ts/issues](https://github.com/nvisycom/sdk-ts/issues)
79
+ - **Email**: [support@nvisy.com](mailto:support@nvisy.com)
@@ -1,15 +1,6 @@
1
- import { C as ClientConfig } from '../config-L7FKq_q5.js';
2
- import { L as Login, A as AuthToken, S as Signup } from '../auth-CncOz2vx.js';
3
-
4
- /**
5
- * @fileoverview Configuration types for standalone auth functions.
6
- *
7
- * This module provides configuration options for authentication operations
8
- * that don't require an existing API token.
9
- *
10
- * @module auth/config
11
- */
12
-
1
+ import { t as ClientConfig } from "../config-BRQp8Cat.js";
2
+ import { At as Signup, Ot as AuthToken, kt as Login } from "../index-Cmm2g3SG.js";
3
+ //#region src/auth/config.d.ts
13
4
  /**
14
5
  * Configuration options for standalone authentication functions.
15
6
  *
@@ -27,29 +18,8 @@ import { L as Login, A as AuthToken, S as Signup } from '../auth-CncOz2vx.js';
27
18
  * ```
28
19
  */
29
20
  type AuthConfig = Omit<ClientConfig, "apiToken">;
30
-
31
- /**
32
- * @fileoverview Standalone password-based authentication functions.
33
- *
34
- * This module provides functions for login and signup that don't require
35
- * an existing API token. Use these to obtain an auth token, then create
36
- * an authenticated {@link Client} instance.
37
- *
38
- * @module auth/password
39
- *
40
- * @example
41
- * ```typescript
42
- * import { login, signup } from "@nvisy/sdk/auth";
43
- * import { Nvisy } from "@nvisy/sdk";
44
- *
45
- * // Login to get a token
46
- * const token = await login({ email: "user@example.com", password: "..." });
47
- *
48
- * // Create authenticated client
49
- * const nvisy = new Nvisy({ apiToken: token.accessToken });
50
- * ```
51
- */
52
-
21
+ //#endregion
22
+ //#region src/auth/password.d.ts
53
23
  /**
54
24
  * Login with email and password to obtain an auth token.
55
25
  *
@@ -101,5 +71,6 @@ declare function login(credentials: Login, config?: AuthConfig): Promise<AuthTok
101
71
  * ```
102
72
  */
103
73
  declare function signup(details: Signup, config?: AuthConfig): Promise<AuthToken>;
104
-
74
+ //#endregion
105
75
  export { type AuthConfig, login, signup };
76
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/auth/config.ts","../../src/auth/password.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KA2BY,aAAa,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCiDR,MACrB,aAAa,OACb,SAAS,aACP,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiCW,OACrB,SAAS,QACT,SAAS,aACP,QAAQ"}
@@ -1,184 +1,106 @@
1
- import createClient from 'openapi-fetch';
1
+ import { i as DEFAULTS, t as errorMiddleware } from "../error-DmkKaDjI.js";
2
+ import createClient from "openapi-fetch";
2
3
 
3
- // src/auth/password.ts
4
-
5
- // src/config.ts
6
- var VERSION = "0.3.0";
7
- var DEFAULTS = {
8
- /**
9
- * Default base URL for the Nvisy API.
10
- */
11
- BASE_URL: "https://api.nvisy.com",
12
- /**
13
- * Default user agent string.
14
- */
15
- USER_AGENT: `@nvisy/sdk v.${VERSION}`
16
- };
17
-
18
- // src/errors.ts
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 {
38
- /**
39
- * The error type identifier (e.g., "ValidationError", "NotFoundError").
40
- */
41
- name;
42
- /**
43
- * Human-readable error message safe for display to end users.
44
- */
45
- message;
46
- /**
47
- * The resource type that the error relates to (e.g., "account", "project").
48
- * May be null if the error is not resource-specific.
49
- */
50
- resource;
51
- /**
52
- * A helpful suggestion for resolving the error.
53
- * May be null if no suggestion is available.
54
- */
55
- suggestion;
56
- /**
57
- * Field-specific validation errors.
58
- * Present when the error is due to invalid input data.
59
- */
60
- validation;
61
- /**
62
- * HTTP status code of the response (e.g., 400, 404, 500).
63
- */
64
- statusCode;
65
- /**
66
- * Creates a new NvisyApiError from an API error response.
67
- *
68
- * @param response - The error response from the API
69
- * @param statusCode - The HTTP status code of the response
70
- */
71
- constructor(response, statusCode) {
72
- super(response.message);
73
- this.name = response.name;
74
- this.message = response.message;
75
- this.resource = response.resource;
76
- this.suggestion = response.suggestion;
77
- this.validation = response.validation;
78
- this.statusCode = statusCode;
79
- if (Error.captureStackTrace) {
80
- Error.captureStackTrace(this, this.constructor);
81
- }
82
- }
83
- /**
84
- * Checks if this is a client error (4xx status code).
85
- *
86
- * Client errors indicate problems with the request itself, such as
87
- * invalid input, missing authentication, or accessing non-existent resources.
88
- *
89
- * @returns True if the status code is in the 4xx range
90
- */
91
- isClientError() {
92
- return this.statusCode >= 400 && this.statusCode < 500;
93
- }
94
- /**
95
- * Checks if this is a server error (5xx status code).
96
- *
97
- * Server errors indicate problems on the API side. These are typically
98
- * transient and may succeed if retried.
99
- *
100
- * @returns True if the status code is in the 5xx range
101
- */
102
- isServerError() {
103
- return this.statusCode >= 500;
104
- }
105
- /**
106
- * Determines if this error is safe to retry.
107
- *
108
- * An error is considered retryable if it's a server error (5xx),
109
- * a request timeout (408), or rate limiting (429).
110
- *
111
- * @returns True if the request may succeed on retry
112
- */
113
- isRetryable() {
114
- return this.statusCode >= 500 || // Server errors
115
- this.statusCode === 408 || // Request timeout
116
- this.statusCode === 429;
117
- }
118
- /**
119
- * Converts the error to a plain {@link ErrorResponse} object.
120
- *
121
- * Useful for serialization or logging.
122
- *
123
- * @returns A plain object representation of the error
124
- */
125
- toJSON() {
126
- return {
127
- name: this.name,
128
- message: this.message,
129
- resource: this.resource,
130
- suggestion: this.suggestion,
131
- validation: this.validation
132
- };
133
- }
134
- };
135
-
136
- // src/middleware/error.ts
137
- var errorMiddleware = {
138
- async onResponse({ response }) {
139
- if (!response.ok) {
140
- const error = await response.clone().json();
141
- throw new NvisyApiError(error, response.status);
142
- }
143
- return response;
144
- },
145
- onError({ error }) {
146
- if (error instanceof Error) {
147
- throw new NvisyError(error.message);
148
- }
149
- throw new NvisyError("An unknown network error occurred");
150
- }
151
- };
152
-
153
- // src/auth/password.ts
4
+ //#region src/auth/password.ts
5
+ /**
6
+ * @fileoverview Standalone password-based authentication functions.
7
+ *
8
+ * This module provides functions for login and signup that don't require
9
+ * an existing API token. Use these to obtain an auth token, then create
10
+ * an authenticated {@link Client} instance.
11
+ *
12
+ * @module auth/password
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { login, signup } from "@nvisy/sdk/auth";
17
+ * import { Nvisy } from "@nvisy/sdk";
18
+ *
19
+ * // Login to get a token
20
+ * const token = await login({ email: "user@example.com", password: "..." });
21
+ *
22
+ * // Create authenticated client
23
+ * const nvisy = new Nvisy({ apiToken: token.accessToken });
24
+ * ```
25
+ */
26
+ /**
27
+ * Creates an unauthenticated API client for auth operations.
28
+ *
29
+ * @param config - Optional configuration options
30
+ * @returns A configured openapi-fetch client without authentication
31
+ * @internal
32
+ */
154
33
  function createAuthClient(config) {
155
- const headers = {
156
- "Content-Type": "application/json",
157
- "User-Agent": config?.userAgent ?? DEFAULTS.USER_AGENT,
158
- ...config?.headers
159
- };
160
- const client = createClient({
161
- baseUrl: config?.baseUrl ?? DEFAULTS.BASE_URL,
162
- headers
163
- });
164
- client.use(errorMiddleware);
165
- return client;
34
+ const headers = {
35
+ "Content-Type": "application/json",
36
+ "User-Agent": config?.userAgent ?? DEFAULTS.USER_AGENT,
37
+ ...config?.headers
38
+ };
39
+ const client = createClient({
40
+ baseUrl: config?.baseUrl ?? DEFAULTS.BASE_URL,
41
+ headers
42
+ });
43
+ client.use(errorMiddleware);
44
+ return client;
166
45
  }
46
+ /**
47
+ * Login with email and password to obtain an auth token.
48
+ *
49
+ * This is a standalone function that doesn't require an existing {@link Client}
50
+ * instance. Use the returned token to create an authenticated client.
51
+ *
52
+ * @param credentials - Login credentials (email and password)
53
+ * @param config - Optional configuration (baseUrl, headers, userAgent)
54
+ * @returns Promise that resolves with the auth token
55
+ * @throws {ApiError} If the credentials are invalid or the request fails
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { login } from "@nvisy/sdk/auth";
60
+ * import { Nvisy } from "@nvisy/sdk";
61
+ *
62
+ * const token = await login({
63
+ * email: "user@example.com",
64
+ * password: "your-password",
65
+ * });
66
+ *
67
+ * const nvisy = new Nvisy({ apiToken: token.accessToken });
68
+ * ```
69
+ */
167
70
  async function login(credentials, config) {
168
- const client = createAuthClient(config);
169
- const { data } = await client.POST("/auth/login", {
170
- body: credentials
171
- });
172
- return data;
71
+ const { data } = await createAuthClient(config).POST("/auth/login/", { body: credentials });
72
+ return data;
173
73
  }
74
+ /**
75
+ * Sign up a new account to obtain an auth token.
76
+ *
77
+ * This is a standalone function that doesn't require an existing {@link Client}
78
+ * instance. Use the returned token to create an authenticated client.
79
+ *
80
+ * @param details - Signup details (name, email, password, etc.)
81
+ * @param config - Optional configuration (baseUrl, headers, userAgent)
82
+ * @returns Promise that resolves with the auth token
83
+ * @throws {ApiError} If the signup fails (e.g., email already exists)
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * import { signup } from "@nvisy/sdk/auth";
88
+ * import { Nvisy } from "@nvisy/sdk";
89
+ *
90
+ * const token = await signup({
91
+ * name: "John Doe",
92
+ * email: "john@example.com",
93
+ * password: "secure-password",
94
+ * });
95
+ *
96
+ * const nvisy = new Nvisy({ apiToken: token.accessToken });
97
+ * ```
98
+ */
174
99
  async function signup(details, config) {
175
- const client = createAuthClient(config);
176
- const { data } = await client.POST("/auth/signup", {
177
- body: details
178
- });
179
- return data;
100
+ const { data } = await createAuthClient(config).POST("/auth/signup/", { body: details });
101
+ return data;
180
102
  }
181
103
 
104
+ //#endregion
182
105
  export { login, signup };
183
- //# sourceMappingURL=index.js.map
184
106
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config.ts","../../src/errors.ts","../../src/middleware/error.ts","../../src/auth/password.ts"],"names":[],"mappings":";;;;;AAcO,IAAM,OAAA,GAAU,OAAA;AA8DhB,IAAM,QAAA,GAAW;AAAA;AAAA;AAAA;AAAA,EAIvB,QAAA,EAAU,uBAAA;AAAA;AAAA;AAAA;AAAA,EAKV,UAAA,EAAY,gBAAgB,OAAO,CAAA;AACpC,CAAA;;;ACtDO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA;AAAA;AAAA;AAAA,EAIrB,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhB,YAAY,OAAA,EAAiB;AAC5B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,KAAK,WAAA,CAAY,IAAA;AAE7B,IAAA,IAAI,MAAM,iBAAA,EAAmB;AAC5B,MAAA,KAAA,CAAM,iBAAA,CAAkB,IAAA,EAAM,IAAA,CAAK,WAAW,CAAA;AAAA,IAC/C;AAAA,EACD;AACD,CAAA;AAwBO,IAAM,aAAA,GAAN,cAA4B,UAAA,CAAoC;AAAA;AAAA;AAAA;AAAA,EAItD,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQhB,WAAA,CAAY,UAAyB,UAAA,EAAoB;AACxD,IAAA,KAAA,CAAM,SAAS,OAAO,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,EACqB;AACrB,EAAA,MAAM,MAAA,GAAS,iBAAiB,MAAM,CAAA;AACtC,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,MAAA,CAAO,KAAK,cAAA,EAAgB;AAAA,IAClD,IAAA,EAAM;AAAA,GACN,CAAA;AACD,EAAA,OAAO,IAAA;AACR","file":"index.js","sourcesContent":["/**\n * @fileoverview Configuration types and constants for the Nvisy SDK.\n *\n * This module provides configuration interfaces, default values, and environment\n * variable names used throughout the SDK.\n *\n * @module config\n */\n\n/**\n * Current SDK version.\n *\n * Used in the default user agent string and for version tracking.\n */\nexport const VERSION = \"0.3.0\";\n\n/**\n * Configuration options for creating a Nvisy client.\n *\n * The `apiToken` field is required for authentication. All other fields are optional\n * and will use sensible defaults when omitted.\n *\n * @example\n * ```typescript\n * const config: ClientConfig = {\n * apiToken: \"your-api-token\",\n * baseUrl: \"https://api.nvisy.com\",\n * headers: { \"X-Custom-Header\": \"value\" },\n * };\n * const client = new Client(config);\n * ```\n */\nexport interface ClientConfig {\n\t/**\n\t * API token for authentication.\n\t *\n\t * Tokens can be obtained from the Nvisy dashboard or via the auth endpoints.\n\t */\n\tapiToken: string;\n\n\t/**\n\t * Base URL for the Nvisy API.\n\t *\n\t * @default \"https://api.nvisy.com\"\n\t */\n\tbaseUrl?: string;\n\n\t/**\n\t * Custom headers to include with every request.\n\t *\n\t * These headers are merged with the default headers (Content-Type, User-Agent,\n\t * and Authorization). Custom headers take precedence over defaults if there\n\t * are conflicts.\n\t */\n\theaders?: Record<string, string>;\n\n\t/**\n\t * Custom user agent string to identify your application.\n\t *\n\t * @default \"@nvisy/sdk v.{version}\"\n\t */\n\tuserAgent?: string;\n\n\t/**\n\t * Enable logging for requests and responses.\n\t *\n\t * When enabled, logs request method, URL, status, and timing to console.\n\t *\n\t * @default false\n\t */\n\twithLogging?: boolean;\n}\n\n/**\n * Default configuration values used when options are not explicitly provided.\n */\nexport const DEFAULTS = {\n\t/**\n\t * Default base URL for the Nvisy API.\n\t */\n\tBASE_URL: \"https://api.nvisy.com\",\n\n\t/**\n\t * Default user agent string.\n\t */\n\tUSER_AGENT: `@nvisy/sdk v.${VERSION}`,\n} as const;\n","/**\n * @fileoverview Error types for the Nvisy SDK.\n *\n * This module defines the error hierarchy used throughout the SDK:\n * - {@link NvisyError} - Base error class for all SDK errors\n * - {@link NvisyApiError} - Errors returned by the Nvisy API (4xx/5xx responses)\n *\n * @module errors\n */\n\nimport type { ErrorResponse } from \"@/datatypes/index.js\";\n\n// Re-export ErrorResponse type for convenience\nexport type { ErrorResponse } from \"@/datatypes/index.js\";\n\n/**\n * Base error class for all Nvisy SDK errors.\n *\n * This class provides common functionality for all SDK errors.\n * It ensures proper error naming and stack traces.\n *\n * @example\n * ```typescript\n * try {\n * const client = new Client({ apiToken: \"\" });\n * } catch (error) {\n * if (error instanceof NvisyError) {\n * console.log(\"SDK error:\", error.message);\n * }\n * }\n * ```\n */\nexport class NvisyError extends Error {\n\t/**\n\t * The error class name.\n\t */\n\tpublic readonly name: string;\n\n\t/**\n\t * Creates a new NvisyError.\n\t *\n\t * @param message - The error message\n\t */\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = this.constructor.name;\n\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, this.constructor);\n\t\t}\n\t}\n}\n\n/**\n * Error thrown when the Nvisy API returns an error response.\n *\n * This error class wraps the API's {@link ErrorResponse} format and adds\n * the HTTP status code. It provides helper methods to categorize errors\n * and determine if they are retryable.\n *\n * @example\n * ```typescript\n * try {\n * await client.account.getAccount();\n * } catch (error) {\n * if (error instanceof NvisyApiError) {\n * console.log(`API Error: ${error.message}`);\n * console.log(`Status: ${error.statusCode}`);\n * if (error.isRetryable()) {\n * // Implement retry logic\n * }\n * }\n * }\n * ```\n */\nexport class NvisyApiError extends NvisyError implements ErrorResponse {\n\t/**\n\t * The error type identifier (e.g., \"ValidationError\", \"NotFoundError\").\n\t */\n\tpublic readonly name: string;\n\n\t/**\n\t * Human-readable error message safe for display to end users.\n\t */\n\tpublic readonly message: string;\n\n\t/**\n\t * The resource type that the error relates to (e.g., \"account\", \"project\").\n\t * May be null if the error is not resource-specific.\n\t */\n\tpublic readonly resource?: string | null;\n\n\t/**\n\t * A helpful suggestion for resolving the error.\n\t * May be null if no suggestion is available.\n\t */\n\tpublic readonly suggestion?: string | null;\n\n\t/**\n\t * Field-specific validation errors.\n\t * Present when the error is due to invalid input data.\n\t */\n\tpublic readonly validation?: ErrorResponse[\"validation\"];\n\n\t/**\n\t * HTTP status code of the response (e.g., 400, 404, 500).\n\t */\n\tpublic readonly statusCode: number;\n\n\t/**\n\t * Creates a new NvisyApiError from an API error response.\n\t *\n\t * @param response - The error response from the API\n\t * @param statusCode - The HTTP status code of the response\n\t */\n\tconstructor(response: ErrorResponse, statusCode: number) {\n\t\tsuper(response.message);\n\t\tthis.name = response.name;\n\t\tthis.message = response.message;\n\t\tthis.resource = response.resource;\n\t\tthis.suggestion = response.suggestion;\n\t\tthis.validation = response.validation;\n\t\tthis.statusCode = statusCode;\n\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, this.constructor);\n\t\t}\n\t}\n\n\t/**\n\t * Checks if this is a client error (4xx status code).\n\t *\n\t * Client errors indicate problems with the request itself, such as\n\t * invalid input, missing authentication, or accessing non-existent resources.\n\t *\n\t * @returns True if the status code is in the 4xx range\n\t */\n\tisClientError(): boolean {\n\t\treturn this.statusCode >= 400 && this.statusCode < 500;\n\t}\n\n\t/**\n\t * Checks if this is a server error (5xx status code).\n\t *\n\t * Server errors indicate problems on the API side. These are typically\n\t * transient and may succeed if retried.\n\t *\n\t * @returns True if the status code is in the 5xx range\n\t */\n\tisServerError(): boolean {\n\t\treturn this.statusCode >= 500;\n\t}\n\n\t/**\n\t * Determines if this error is safe to retry.\n\t *\n\t * An error is considered retryable if it's a server error (5xx),\n\t * a request timeout (408), or rate limiting (429).\n\t *\n\t * @returns True if the request may succeed on retry\n\t */\n\tisRetryable(): boolean {\n\t\treturn (\n\t\t\tthis.statusCode >= 500 || // Server errors\n\t\t\tthis.statusCode === 408 || // Request timeout\n\t\t\tthis.statusCode === 429 // Rate limited\n\t\t);\n\t}\n\n\t/**\n\t * Converts the error to a plain {@link ErrorResponse} object.\n\t *\n\t * Useful for serialization or logging.\n\t *\n\t * @returns A plain object representation of the error\n\t */\n\ttoJSON(): ErrorResponse {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tresource: this.resource,\n\t\t\tsuggestion: this.suggestion,\n\t\t\tvalidation: this.validation,\n\t\t};\n\t}\n}\n","import type { Middleware } from \"openapi-fetch\";\nimport type { ErrorResponse } from \"@/datatypes/index.js\";\nimport { NvisyApiError, NvisyError } from \"@/errors.js\";\n\n/**\n * Middleware that automatically throws NvisyApiError for error responses.\n * This replaces the need for manual checks in services.\n */\nexport const errorMiddleware: Middleware = {\n\tasync onResponse({ response }) {\n\t\tif (!response.ok) {\n\t\t\tconst error = (await response.clone().json()) as ErrorResponse;\n\t\t\tthrow new NvisyApiError(error, response.status);\n\t\t}\n\t\treturn response;\n\t},\n\n\tonError({ error }) {\n\t\t// Wrap fetch errors (network failures, CORS, etc.) in NvisyError\n\t\tif (error instanceof Error) {\n\t\t\tthrow new NvisyError(error.message);\n\t\t}\n\t\tthrow new NvisyError(\"An unknown network error occurred\");\n\t},\n};\n","/**\n * @fileoverview Standalone password-based authentication functions.\n *\n * This module provides functions for login and signup that don't require\n * an existing API token. Use these to obtain an auth token, then create\n * an authenticated {@link Client} instance.\n *\n * @module auth/password\n *\n * @example\n * ```typescript\n * import { login, signup } from \"@nvisy/sdk/auth\";\n * import { Nvisy } from \"@nvisy/sdk\";\n *\n * // Login to get a token\n * const token = await login({ email: \"user@example.com\", password: \"...\" });\n *\n * // Create authenticated client\n * const nvisy = new Nvisy({ apiToken: token.accessToken });\n * ```\n */\n\nimport createClient from \"openapi-fetch\";\nimport type { AuthConfig } from \"@/auth/config.js\";\nimport { DEFAULTS } from \"@/config.js\";\nimport type { AuthToken, Login, Signup } from \"@/datatypes/index.js\";\nimport { errorMiddleware } from \"@/middleware/index.js\";\nimport type { paths } from \"@/schema/api.js\";\n\n/**\n * Creates an unauthenticated API client for auth operations.\n *\n * @param config - Optional configuration options\n * @returns A configured openapi-fetch client without authentication\n * @internal\n */\nfunction createAuthClient(config?: AuthConfig) {\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\t\"User-Agent\": config?.userAgent ?? DEFAULTS.USER_AGENT,\n\t\t...config?.headers,\n\t};\n\n\tconst client = createClient<paths>({\n\t\tbaseUrl: config?.baseUrl ?? DEFAULTS.BASE_URL,\n\t\theaders,\n\t});\n\n\tclient.use(errorMiddleware);\n\treturn client;\n}\n\n/**\n * Login with email and password to obtain an auth token.\n *\n * This is a standalone function that doesn't require an existing {@link Client}\n * instance. Use the returned token to create an authenticated client.\n *\n * @param credentials - Login credentials (email and password)\n * @param config - Optional configuration (baseUrl, headers, userAgent)\n * @returns Promise that resolves with the auth token\n * @throws {ApiError} If the credentials are invalid or the request fails\n *\n * @example\n * ```typescript\n * import { login } from \"@nvisy/sdk/auth\";\n * import { Nvisy } from \"@nvisy/sdk\";\n *\n * const token = await login({\n * email: \"user@example.com\",\n * password: \"your-password\",\n * });\n *\n * const nvisy = new Nvisy({ apiToken: token.accessToken });\n * ```\n */\nexport async function login(\n\tcredentials: Login,\n\tconfig?: AuthConfig,\n): Promise<AuthToken> {\n\tconst client = createAuthClient(config);\n\tconst { data } = await client.POST(\"/auth/login\", {\n\t\tbody: credentials,\n\t});\n\treturn data!;\n}\n\n/**\n * Sign up a new account to obtain an auth token.\n *\n * This is a standalone function that doesn't require an existing {@link Client}\n * instance. Use the returned token to create an authenticated client.\n *\n * @param details - Signup details (name, email, password, etc.)\n * @param config - Optional configuration (baseUrl, headers, userAgent)\n * @returns Promise that resolves with the auth token\n * @throws {ApiError} If the signup fails (e.g., email already exists)\n *\n * @example\n * ```typescript\n * import { signup } from \"@nvisy/sdk/auth\";\n * import { Nvisy } from \"@nvisy/sdk\";\n *\n * const token = await signup({\n * name: \"John Doe\",\n * email: \"john@example.com\",\n * password: \"secure-password\",\n * });\n *\n * const nvisy = new Nvisy({ apiToken: token.accessToken });\n * ```\n */\nexport async function signup(\n\tdetails: Signup,\n\tconfig?: AuthConfig,\n): Promise<AuthToken> {\n\tconst client = createAuthClient(config);\n\tconst { data } = await client.POST(\"/auth/signup\", {\n\t\tbody: details,\n\t});\n\treturn data!;\n}\n"]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/auth/password.ts"],"sourcesContent":["/**\n * @fileoverview Standalone password-based authentication functions.\n *\n * This module provides functions for login and signup that don't require\n * an existing API token. Use these to obtain an auth token, then create\n * an authenticated {@link Client} instance.\n *\n * @module auth/password\n *\n * @example\n * ```typescript\n * import { login, signup } from \"@nvisy/sdk/auth\";\n * import { Nvisy } from \"@nvisy/sdk\";\n *\n * // Login to get a token\n * const token = await login({ email: \"user@example.com\", password: \"...\" });\n *\n * // Create authenticated client\n * const nvisy = new Nvisy({ apiToken: token.accessToken });\n * ```\n */\n\nimport createClient from \"openapi-fetch\";\nimport type { AuthConfig } from \"@/auth/config.js\";\nimport { DEFAULTS } from \"@/config.js\";\nimport type { AuthToken, Login, Signup } from \"@/datatypes/index.js\";\nimport { errorMiddleware } from \"@/middleware/index.js\";\nimport type { paths } from \"@/schema/api.js\";\n\n/**\n * Creates an unauthenticated API client for auth operations.\n *\n * @param config - Optional configuration options\n * @returns A configured openapi-fetch client without authentication\n * @internal\n */\nfunction createAuthClient(config?: AuthConfig) {\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\t\"User-Agent\": config?.userAgent ?? DEFAULTS.USER_AGENT,\n\t\t...config?.headers,\n\t};\n\n\tconst client = createClient<paths>({\n\t\tbaseUrl: config?.baseUrl ?? DEFAULTS.BASE_URL,\n\t\theaders,\n\t});\n\n\tclient.use(errorMiddleware);\n\treturn client;\n}\n\n/**\n * Login with email and password to obtain an auth token.\n *\n * This is a standalone function that doesn't require an existing {@link Client}\n * instance. Use the returned token to create an authenticated client.\n *\n * @param credentials - Login credentials (email and password)\n * @param config - Optional configuration (baseUrl, headers, userAgent)\n * @returns Promise that resolves with the auth token\n * @throws {ApiError} If the credentials are invalid or the request fails\n *\n * @example\n * ```typescript\n * import { login } from \"@nvisy/sdk/auth\";\n * import { Nvisy } from \"@nvisy/sdk\";\n *\n * const token = await login({\n * email: \"user@example.com\",\n * password: \"your-password\",\n * });\n *\n * const nvisy = new Nvisy({ apiToken: token.accessToken });\n * ```\n */\nexport async function login(\n\tcredentials: Login,\n\tconfig?: AuthConfig,\n): Promise<AuthToken> {\n\tconst client = createAuthClient(config);\n\tconst { data } = await client.POST(\"/auth/login/\", {\n\t\tbody: credentials,\n\t});\n\treturn data!;\n}\n\n/**\n * Sign up a new account to obtain an auth token.\n *\n * This is a standalone function that doesn't require an existing {@link Client}\n * instance. Use the returned token to create an authenticated client.\n *\n * @param details - Signup details (name, email, password, etc.)\n * @param config - Optional configuration (baseUrl, headers, userAgent)\n * @returns Promise that resolves with the auth token\n * @throws {ApiError} If the signup fails (e.g., email already exists)\n *\n * @example\n * ```typescript\n * import { signup } from \"@nvisy/sdk/auth\";\n * import { Nvisy } from \"@nvisy/sdk\";\n *\n * const token = await signup({\n * name: \"John Doe\",\n * email: \"john@example.com\",\n * password: \"secure-password\",\n * });\n *\n * const nvisy = new Nvisy({ apiToken: token.accessToken });\n * ```\n */\nexport async function signup(\n\tdetails: Signup,\n\tconfig?: AuthConfig,\n): Promise<AuthToken> {\n\tconst client = createAuthClient(config);\n\tconst { data } = await client.POST(\"/auth/signup/\", {\n\t\tbody: details,\n\t});\n\treturn data!;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,iBAAiB,QAAqB;CAC9C,MAAM,UAAkC;EACvC,gBAAgB;EAChB,cAAc,QAAQ,aAAa,SAAS;EAC5C,GAAG,QAAQ;CACZ;CAEA,MAAM,SAAS,aAAoB;EAClC,SAAS,QAAQ,WAAW,SAAS;EACrC;CACD,CAAC;CAED,OAAO,IAAI,eAAe;CAC1B,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,eAAsB,MACrB,aACA,QACqB;CAErB,MAAM,EAAE,SAAS,MADF,iBAAiB,MACJ,CAAC,CAAC,KAAK,gBAAgB,EAClD,MAAM,YACP,CAAC;CACD,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,eAAsB,OACrB,SACA,QACqB;CAErB,MAAM,EAAE,SAAS,MADF,iBAAiB,MACJ,CAAC,CAAC,KAAK,iBAAiB,EACnD,MAAM,QACP,CAAC;CACD,OAAO;AACR"}