@nvisy/sdk 0.53.0 → 0.54.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 +34 -1
- package/dist/datatypes/index.d.ts +2 -2
- package/dist/{errors-aOivXE8A.d.ts → errors-DShmkdjS.d.ts} +2 -2
- package/dist/{errors-aOivXE8A.d.ts.map → errors-DShmkdjS.d.ts.map} +1 -1
- package/dist/guest/index.d.ts +38 -0
- package/dist/guest/index.d.ts.map +1 -0
- package/dist/guest/index.js +56 -0
- package/dist/guest/index.js.map +1 -0
- package/dist/http-BexRclA5.js +128 -0
- package/dist/http-BexRclA5.js.map +1 -0
- package/dist/{client-DywPcOzJ.d.ts → index-DFbHT_eq.d.ts} +355 -216
- package/dist/index-DFbHT_eq.d.ts.map +1 -0
- package/dist/{index-rc5Y8RNG.d.ts → index-DzEtj1r2.d.ts} +109 -51
- package/dist/index-DzEtj1r2.d.ts.map +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +22 -117
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.js +2 -2
- package/dist/{services-DFJfjW1b.js → services-BMmcawiT.js} +117 -60
- package/dist/services-BMmcawiT.js.map +1 -0
- package/dist/webhooks/index.d.ts +2 -2
- package/package.json +4 -4
- package/dist/client-DywPcOzJ.d.ts.map +0 -1
- package/dist/config-BdAgnJlh.d.ts +0 -103
- package/dist/config-BdAgnJlh.d.ts.map +0 -1
- package/dist/error-D_h2zq6T.js +0 -47
- package/dist/error-D_h2zq6T.js.map +0 -1
- package/dist/index-rc5Y8RNG.d.ts.map +0 -1
- package/dist/services-DFJfjW1b.js.map +0 -1
- package/dist/standalone/index.d.ts +0 -117
- package/dist/standalone/index.d.ts.map +0 -1
- package/dist/standalone/index.js +0 -153
- package/dist/standalone/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,63 +1,9 @@
|
|
|
1
|
-
import { n as DEFAULTS, r as VERSION, t as errorMiddleware } from "./error-D_h2zq6T.js";
|
|
2
1
|
import { n as NvisyError, t as NvisyApiError } from "./errors-ChRSBkhj.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import { i as VERSION, n as resolveDefaults, r as DEFAULTS, t as createApiClient } from "./http-BexRclA5.js";
|
|
3
|
+
import { C as Activities, S as Analytics, _ as Detections, a as Status, b as Auth, c as Providers, d as Notifications, f as Members, g as Documents, i as Syncs, l as Policies, n as Webhooks, o as Reviews, p as Invites, r as Threads, s as Redactions, t as Workspaces, u as Pipelines, v as Connections, w as Account, x as ApiTokens, y as Capabilities } from "./services-BMmcawiT.js";
|
|
5
4
|
|
|
6
|
-
//#region src/middleware/logging.ts
|
|
7
|
-
/**
|
|
8
|
-
* Creates a logging middleware for debugging requests and responses.
|
|
9
|
-
*
|
|
10
|
-
* Logs request method, URL, response status, and timing to console.
|
|
11
|
-
*/
|
|
12
|
-
function createLoggingMiddleware() {
|
|
13
|
-
return {
|
|
14
|
-
async onRequest({ request }) {
|
|
15
|
-
request._startTime = performance.now();
|
|
16
|
-
return request;
|
|
17
|
-
},
|
|
18
|
-
async onResponse({ request, response }) {
|
|
19
|
-
const start = request._startTime ?? performance.now();
|
|
20
|
-
const duration = Math.round(performance.now() - start);
|
|
21
|
-
const url = new URL(request.url);
|
|
22
|
-
console.log(`[nvisy] ${request.method} ${url.pathname} ${response.status} (${duration}ms)`);
|
|
23
|
-
if (!response.ok) {
|
|
24
|
-
const cloned = response.clone();
|
|
25
|
-
try {
|
|
26
|
-
const body = await cloned.json();
|
|
27
|
-
console.error("[nvisy] Response:", JSON.stringify(body, null, 2));
|
|
28
|
-
} catch {
|
|
29
|
-
const text = await cloned.text();
|
|
30
|
-
if (text) console.error("[nvisy] Response:", text);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return response;
|
|
34
|
-
},
|
|
35
|
-
onError({ request, error }) {
|
|
36
|
-
const start = request._startTime ?? performance.now();
|
|
37
|
-
const duration = Math.round(performance.now() - start);
|
|
38
|
-
const url = new URL(request.url);
|
|
39
|
-
console.error(`[nvisy] ${request.method} ${url.pathname} ERROR (${duration}ms):`, error instanceof Error ? error.message : error);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
5
|
//#region src/client.ts
|
|
46
6
|
/**
|
|
47
|
-
* @fileoverview Main client for the Nvisy SDK.
|
|
48
|
-
*
|
|
49
|
-
* This module exports the {@link Nvisy} class, which is the primary entry point
|
|
50
|
-
* for interacting with the Nvisy document processing API.
|
|
51
|
-
*
|
|
52
|
-
* @module client
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const nvisy = new Nvisy({ apiToken: "your-api-token" });
|
|
57
|
-
* const account = await nvisy.account.getAccount();
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
/**
|
|
61
7
|
* Main client class for interacting with the Nvisy document processing API.
|
|
62
8
|
*
|
|
63
9
|
* @example
|
|
@@ -68,83 +14,41 @@ function createLoggingMiddleware() {
|
|
|
68
14
|
* ```
|
|
69
15
|
*/
|
|
70
16
|
var Nvisy = class Nvisy {
|
|
71
|
-
/**
|
|
72
|
-
* The resolved client configuration with defaults applied.
|
|
73
|
-
* @internal
|
|
74
|
-
*/
|
|
17
|
+
/** The config this client was built from (for {@link withApiToken}). @internal */
|
|
75
18
|
#config;
|
|
19
|
+
/** The resolved base URL. @internal */
|
|
20
|
+
#baseUrl;
|
|
76
21
|
/**
|
|
77
22
|
* The underlying openapi-fetch client instance.
|
|
78
23
|
* @internal
|
|
79
24
|
*/
|
|
80
25
|
#api;
|
|
81
26
|
/**
|
|
82
|
-
* Creates a new Nvisy client
|
|
27
|
+
* Creates a new authenticated Nvisy client.
|
|
83
28
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
29
|
+
* Requires an `apiToken` (sent as `Authorization: Bearer <token>`). For the
|
|
30
|
+
* pre-auth surface (login / signup / OIDC start, auth capabilities, health),
|
|
31
|
+
* use {@link NvisyGuest} from `@nvisy/sdk/guest`.
|
|
87
32
|
*
|
|
88
|
-
* @param config - Configuration options
|
|
89
|
-
* @throws {NvisyError} If
|
|
33
|
+
* @param config - Configuration options with a required `apiToken`
|
|
34
|
+
* @throws {NvisyError} If the API token is missing or invalid
|
|
90
35
|
*
|
|
91
36
|
* @example
|
|
92
37
|
* ```typescript
|
|
93
|
-
* // API token
|
|
94
38
|
* const nvisy = new Nvisy({ apiToken: "your-api-token" });
|
|
95
|
-
*
|
|
96
|
-
* // Browser session
|
|
97
|
-
* const nvisy = new Nvisy({ credentials: "include" });
|
|
98
|
-
*
|
|
99
39
|
* const account = await nvisy.account.getAccount();
|
|
100
40
|
* ```
|
|
101
41
|
*/
|
|
102
|
-
constructor(config
|
|
103
|
-
this.#config =
|
|
104
|
-
|
|
42
|
+
constructor(config) {
|
|
43
|
+
this.#config = config;
|
|
44
|
+
const resolved = resolveDefaults(config);
|
|
45
|
+
this.#baseUrl = resolved.baseUrl;
|
|
46
|
+
this.#api = createApiClient({
|
|
47
|
+
apiToken: this.#validateApiToken(config.apiToken),
|
|
105
48
|
credentials: config.credentials,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
userAgent: config.userAgent ?? DEFAULTS.USER_AGENT,
|
|
109
|
-
withLogging: config.withLogging ?? false,
|
|
110
|
-
fetch: config.fetch
|
|
111
|
-
};
|
|
112
|
-
this.#api = this.#createApiClient();
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Creates and configures the underlying openapi-fetch client.
|
|
116
|
-
*
|
|
117
|
-
* @returns A configured ApiClient instance
|
|
118
|
-
* @internal
|
|
119
|
-
*/
|
|
120
|
-
#createApiClient() {
|
|
121
|
-
const headers = {
|
|
122
|
-
"Content-Type": "application/json",
|
|
123
|
-
"User-Agent": this.#config.userAgent,
|
|
124
|
-
...this.#config.apiToken ? { Authorization: `Bearer ${this.#config.apiToken}` } : {},
|
|
125
|
-
...this.#config.headers
|
|
126
|
-
};
|
|
127
|
-
const api = createClient({
|
|
128
|
-
baseUrl: this.#config.baseUrl,
|
|
129
|
-
headers,
|
|
130
|
-
fetch: this.#config.fetch,
|
|
131
|
-
...this.#config.credentials ? { credentials: this.#config.credentials } : {}
|
|
49
|
+
fetch: config.fetch,
|
|
50
|
+
...resolved
|
|
132
51
|
});
|
|
133
|
-
if (this.#config.withLogging) api.use(createLoggingMiddleware());
|
|
134
|
-
api.use(errorMiddleware);
|
|
135
|
-
return api;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Resolves the configured API token: validated when present, or `undefined`
|
|
139
|
-
* for a browser-session client that authenticates with cookies instead.
|
|
140
|
-
*
|
|
141
|
-
* @param apiToken - The configured API token, if any
|
|
142
|
-
* @returns The trimmed, validated token, or `undefined` when none is given
|
|
143
|
-
* @throws {NvisyError} If a token is given but invalid
|
|
144
|
-
* @internal
|
|
145
|
-
*/
|
|
146
|
-
#resolveApiToken(apiToken) {
|
|
147
|
-
return apiToken === void 0 ? void 0 : this.#validateApiToken(apiToken);
|
|
148
52
|
}
|
|
149
53
|
/**
|
|
150
54
|
* Validates an API token format.
|
|
@@ -193,7 +97,7 @@ var Nvisy = class Nvisy {
|
|
|
193
97
|
* @returns The configured base URL
|
|
194
98
|
*/
|
|
195
99
|
get baseUrl() {
|
|
196
|
-
return this.#
|
|
100
|
+
return this.#baseUrl;
|
|
197
101
|
}
|
|
198
102
|
/**
|
|
199
103
|
* The underlying openapi-fetch client for direct API access.
|
|
@@ -207,7 +111,8 @@ var Nvisy = class Nvisy {
|
|
|
207
111
|
return this.#api;
|
|
208
112
|
}
|
|
209
113
|
/**
|
|
210
|
-
* Service for
|
|
114
|
+
* Service for authenticated auth operations (logout, desktop token). Pre-auth
|
|
115
|
+
* sign-in lives on {@link NvisyGuest}.
|
|
211
116
|
*/
|
|
212
117
|
get auth() {
|
|
213
118
|
return new Auth(this.#api);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/middleware/logging.ts","../src/client.ts"],"sourcesContent":["import type { Middleware } from \"openapi-fetch\";\n\n/**\n * Creates a logging middleware for debugging requests and responses.\n *\n * Logs request method, URL, response status, and timing to console.\n */\nexport function createLoggingMiddleware(): Middleware {\n\treturn {\n\t\tasync onRequest({ request }) {\n\t\t\tconst start = performance.now();\n\t\t\t(request as Request & { _startTime?: number })._startTime = start;\n\t\t\treturn request;\n\t\t},\n\n\t\tasync onResponse({ request, response }) {\n\t\t\tconst start =\n\t\t\t\t(request as Request & { _startTime?: number })._startTime ??\n\t\t\t\tperformance.now();\n\t\t\tconst duration = Math.round(performance.now() - start);\n\t\t\tconst url = new URL(request.url);\n\n\t\t\tconsole.log(\n\t\t\t\t`[nvisy] ${request.method} ${url.pathname} ${response.status} (${duration}ms)`,\n\t\t\t);\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst cloned = response.clone();\n\t\t\t\ttry {\n\t\t\t\t\tconst body = await cloned.json();\n\t\t\t\t\tconsole.error(\"[nvisy] Response:\", JSON.stringify(body, null, 2));\n\t\t\t\t} catch {\n\t\t\t\t\tconst text = await cloned.text();\n\t\t\t\t\tif (text) console.error(\"[nvisy] Response:\", text);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn response;\n\t\t},\n\n\t\tonError({ request, error }) {\n\t\t\tconst start =\n\t\t\t\t(request as Request & { _startTime?: number })._startTime ??\n\t\t\t\tperformance.now();\n\t\t\tconst duration = Math.round(performance.now() - start);\n\t\t\tconst url = new URL(request.url);\n\n\t\t\tconsole.error(\n\t\t\t\t`[nvisy] ${request.method} ${url.pathname} ERROR (${duration}ms):`,\n\t\t\t\terror instanceof Error ? error.message : error,\n\t\t\t);\n\t\t},\n\t};\n}\n","/**\n * @fileoverview Main client for the Nvisy SDK.\n *\n * This module exports the {@link Nvisy} class, which is the primary entry point\n * for interacting with the Nvisy document processing API.\n *\n * @module client\n *\n * @example\n * ```typescript\n * const nvisy = new Nvisy({ apiToken: \"your-api-token\" });\n * const account = await nvisy.account.getAccount();\n * ```\n */\n\nimport createClient, { type Client as OpenApiClient } from \"openapi-fetch\";\nimport { type ClientConfig, DEFAULTS } from \"@/config.js\";\nimport { NvisyError } from \"@/errors.js\";\nimport {\n\tcreateLoggingMiddleware,\n\terrorMiddleware,\n} from \"@/middleware/index.js\";\nimport type { paths } from \"@/schema/api.js\";\nimport {\n\tAccount,\n\tActivities,\n\tAnalytics,\n\tApiTokens,\n\tAuth,\n\tCapabilities,\n\tConnections,\n\tDetections,\n\tDocuments,\n\tInvites,\n\tMembers,\n\tNotifications,\n\tPipelines,\n\tPolicies,\n\tProviders,\n\tRedactions,\n\tReviews,\n\tStatus,\n\tSyncs,\n\tThreads,\n\tWebhooks,\n\tWorkspaces,\n} from \"@/services/index.js\";\n\n/**\n * Typed openapi-fetch client for the Nvisy API.\n *\n * This type represents the low-level HTTP client configured with the Nvisy API schema.\n * It's exposed via {@link Nvisy.api} for advanced use cases requiring direct API access.\n */\nexport type ApiClient = OpenApiClient<paths>;\n\n/**\n * Internal configuration state for the client with all fields resolved.\n *\n * @internal\n */\n// `fetch`, `apiToken`, and `credentials` stay optional after resolution: an\n// omitted `fetch` means \"use the global fetch\"; an omitted `apiToken` means a\n// browser-session client (no bearer header); an omitted `credentials` uses the\n// platform default.\ntype ResolvedConfig = Required<\n\tOmit<ClientConfig, \"fetch\" | \"apiToken\" | \"credentials\">\n> &\n\tPick<ClientConfig, \"fetch\" | \"apiToken\" | \"credentials\">;\n\n/**\n * Main client class for interacting with the Nvisy document processing API.\n *\n * @example\n * ```typescript\n * const nvisy = new Nvisy({ apiToken: \"your-api-token\" });\n * const account = await nvisy.account.getAccount();\n * const workspaces = await nvisy.workspaces.listWorkspaces();\n * ```\n */\nexport class Nvisy {\n\t/**\n\t * The resolved client configuration with defaults applied.\n\t * @internal\n\t */\n\treadonly #config: ResolvedConfig;\n\n\t/**\n\t * The underlying openapi-fetch client instance.\n\t * @internal\n\t */\n\treadonly #api: ApiClient;\n\n\t/**\n\t * Creates a new Nvisy client instance.\n\t *\n\t * Authenticate with an `apiToken` (bearer token) or, for a browser session\n\t * started by the standalone `login` / `signup`, with `credentials: \"include\"`\n\t * and no token.\n\t *\n\t * @param config - Configuration options; omit `apiToken` for a cookie session\n\t * @throws {NvisyError} If an `apiToken` is provided but invalid\n\t *\n\t * @example\n\t * ```typescript\n\t * // API token\n\t * const nvisy = new Nvisy({ apiToken: \"your-api-token\" });\n\t *\n\t * // Browser session\n\t * const nvisy = new Nvisy({ credentials: \"include\" });\n\t *\n\t * const account = await nvisy.account.getAccount();\n\t * ```\n\t */\n\tconstructor(config: ClientConfig = {}) {\n\t\tthis.#config = {\n\t\t\tapiToken: this.#resolveApiToken(config.apiToken),\n\t\t\tcredentials: config.credentials,\n\t\t\tbaseUrl: config.baseUrl ?? DEFAULTS.BASE_URL,\n\t\t\theaders: config.headers ?? {},\n\t\t\tuserAgent: config.userAgent ?? DEFAULTS.USER_AGENT,\n\t\t\twithLogging: config.withLogging ?? false,\n\t\t\tfetch: config.fetch,\n\t\t};\n\n\t\tthis.#api = this.#createApiClient();\n\t}\n\n\t/**\n\t * Creates and configures the underlying openapi-fetch client.\n\t *\n\t * @returns A configured ApiClient instance\n\t * @internal\n\t */\n\t#createApiClient(): ApiClient {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\"User-Agent\": this.#config.userAgent,\n\t\t\t// Only send a bearer token when one is configured; a browser-session\n\t\t\t// client authenticates with cookies instead.\n\t\t\t...(this.#config.apiToken\n\t\t\t\t? { Authorization: `Bearer ${this.#config.apiToken}` }\n\t\t\t\t: {}),\n\t\t\t...this.#config.headers,\n\t\t};\n\n\t\tconst api = createClient<paths>({\n\t\t\tbaseUrl: this.#config.baseUrl,\n\t\t\theaders,\n\t\t\t// `undefined` falls back to the global fetch inside openapi-fetch.\n\t\t\tfetch: this.#config.fetch,\n\t\t\t// Omitted `credentials` uses the platform default.\n\t\t\t...(this.#config.credentials\n\t\t\t\t? { credentials: this.#config.credentials }\n\t\t\t\t: {}),\n\t\t});\n\n\t\tif (this.#config.withLogging) {\n\t\t\tapi.use(createLoggingMiddleware());\n\t\t}\n\n\t\tapi.use(errorMiddleware);\n\t\treturn api;\n\t}\n\n\t/**\n\t * Resolves the configured API token: validated when present, or `undefined`\n\t * for a browser-session client that authenticates with cookies instead.\n\t *\n\t * @param apiToken - The configured API token, if any\n\t * @returns The trimmed, validated token, or `undefined` when none is given\n\t * @throws {NvisyError} If a token is given but invalid\n\t * @internal\n\t */\n\t#resolveApiToken(apiToken: string | undefined): string | undefined {\n\t\treturn apiToken === undefined\n\t\t\t? undefined\n\t\t\t: this.#validateApiToken(apiToken);\n\t}\n\n\t/**\n\t * Validates an API token format.\n\t *\n\t * @param apiToken - The API token to validate\n\t * @returns The trimmed API token if valid\n\t * @throws {NvisyError} If the API token is invalid\n\t * @internal\n\t */\n\t#validateApiToken(apiToken: string): string {\n\t\tif (typeof apiToken !== \"string\" || apiToken.trim().length === 0) {\n\t\t\tthrow new NvisyError(\"API token must be a non-empty string\");\n\t\t}\n\n\t\tconst trimmedToken = apiToken.trim();\n\t\tif (trimmedToken.length < 10) {\n\t\t\tthrow new NvisyError(\"API token must be at least 10 characters\");\n\t\t}\n\n\t\tif (!/^[a-zA-Z0-9_.-]+$/.test(trimmedToken)) {\n\t\t\tthrow new NvisyError(\"API token contains invalid characters\");\n\t\t}\n\n\t\treturn trimmedToken;\n\t}\n\n\t/**\n\t * Creates a new client with a different API token.\n\t *\n\t * Returns a new client instance with the new token. The original client\n\t * remains unchanged. All other configuration (base URL, headers, etc.)\n\t * is preserved in the new client.\n\t *\n\t * @param apiToken - The new API token\n\t * @returns A new Nvisy instance with the new token\n\t * @throws {NvisyError} If the API token is invalid\n\t *\n\t * @example\n\t * ```typescript\n\t * const nvisy = new Nvisy({ apiToken: \"original-token\" });\n\t * const newNvisy = nvisy.withApiToken(\"new-token\");\n\t *\n\t * // newNvisy uses the new token\n\t * // nvisy still uses the original token\n\t * ```\n\t */\n\twithApiToken(apiToken: string): Nvisy {\n\t\treturn new Nvisy({ ...this.#config, apiToken });\n\t}\n\n\t/**\n\t * The base URL used for API requests.\n\t *\n\t * @returns The configured base URL\n\t */\n\tget baseUrl(): string {\n\t\treturn this.#config.baseUrl;\n\t}\n\n\t/**\n\t * The underlying openapi-fetch client for direct API access.\n\t *\n\t * Use this for advanced scenarios where you need direct access to the\n\t * HTTP client, such as calling endpoints not covered by the service classes.\n\t *\n\t * @returns The configured ApiClient instance\n\t */\n\tget api(): ApiClient {\n\t\treturn this.#api;\n\t}\n\n\t/**\n\t * Service for authentication operations (login, signup, logout).\n\t */\n\tget auth(): Auth {\n\t\treturn new Auth(this.#api);\n\t}\n\n\t/**\n\t * Service for API status and health checks.\n\t */\n\tget status(): Status {\n\t\treturn new Status(this.#api);\n\t}\n\n\t/**\n\t * Service for managing the authenticated user's account.\n\t */\n\tget account(): Account {\n\t\treturn new Account(this.#api);\n\t}\n\n\t/**\n\t * Service for viewing workspace activities.\n\t */\n\tget activities(): Activities {\n\t\treturn new Activities(this.#api);\n\t}\n\n\t/**\n\t * Service for workspace analytics.\n\t */\n\tget analytics(): Analytics {\n\t\treturn new Analytics(this.#api);\n\t}\n\n\t/**\n\t * Service for managing API tokens.\n\t */\n\tget apiTokens(): ApiTokens {\n\t\treturn new ApiTokens(this.#api);\n\t}\n\n\t/**\n\t * Service for managing connections.\n\t */\n\tget connections(): Connections {\n\t\treturn new Connections(this.#api);\n\t}\n\n\t/**\n\t * Service for document operations (upload, download, delete, review).\n\t */\n\tget documents(): Documents {\n\t\treturn new Documents(this.#api);\n\t}\n\n\t/**\n\t * Service for discussion threads and comments.\n\t */\n\tget threads(): Threads {\n\t\treturn new Threads(this.#api);\n\t}\n\n\t/**\n\t * Service for managing pipelines.\n\t */\n\tget pipelines(): Pipelines {\n\t\treturn new Pipelines(this.#api);\n\t}\n\n\t/**\n\t * Service for managing policies.\n\t */\n\tget policies(): Policies {\n\t\treturn new Policies(this.#api);\n\t}\n\n\t/**\n\t * Service for managing a workspace's inference providers.\n\t */\n\tget providers(): Providers {\n\t\treturn new Providers(this.#api);\n\t}\n\n\t/**\n\t * Service for reading the deployment's capabilities (labels, recognizers,\n\t * connectors, auth methods).\n\t */\n\tget capabilities(): Capabilities {\n\t\treturn new Capabilities(this.#api);\n\t}\n\n\t/**\n\t * Service for managing workspace invitations.\n\t */\n\tget invites(): Invites {\n\t\treturn new Invites(this.#api);\n\t}\n\n\t/**\n\t * Service for managing workspace members.\n\t */\n\tget members(): Members {\n\t\treturn new Members(this.#api);\n\t}\n\n\t/**\n\t * Service for managing notifications.\n\t */\n\tget notifications(): Notifications {\n\t\treturn new Notifications(this.#api);\n\t}\n\n\t/**\n\t * Service for pipeline detections and their redactions.\n\t */\n\tget detections(): Detections {\n\t\treturn new Detections(this.#api);\n\t}\n\n\t/**\n\t * Service for workspace redactions.\n\t */\n\tget redactions(): Redactions {\n\t\treturn new Redactions(this.#api);\n\t}\n\n\t/**\n\t * Service for document reviews (assigning documents to reviewers).\n\t */\n\tget reviews(): Reviews {\n\t\treturn new Reviews(this.#api);\n\t}\n\n\t/**\n\t * Service for managing connection syncs.\n\t */\n\tget syncs(): Syncs {\n\t\treturn new Syncs(this.#api);\n\t}\n\n\t/**\n\t * Service for managing webhooks.\n\t */\n\tget webhooks(): Webhooks {\n\t\treturn new Webhooks(this.#api);\n\t}\n\n\t/**\n\t * Service for managing workspaces.\n\t */\n\tget workspaces(): Workspaces {\n\t\treturn new Workspaces(this.#api);\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAOA,SAAgB,0BAAsC;CACrD,OAAO;EACN,MAAM,UAAU,EAAE,WAAW;GAE5B,AAAC,QAA8C,aADjC,YAAY,IACsC;GAChE,OAAO;EACR;EAEA,MAAM,WAAW,EAAE,SAAS,YAAY;GACvC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IAAI;CAC9B;;;;CAKA,IAAI,aAAyB;EAC5B,OAAO,IAAI,WAAW,KAAK,IAAI;CAChC;AACD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["/**\n * @fileoverview Main client for the Nvisy SDK.\n *\n * This module exports the {@link Nvisy} class, which is the primary entry point\n * for interacting with the Nvisy document processing API.\n *\n * @module client\n *\n * @example\n * ```typescript\n * const nvisy = new Nvisy({ apiToken: \"your-api-token\" });\n * const account = await nvisy.account.getAccount();\n * ```\n */\n\nimport type { NvisyConfig } from \"@/config.js\";\nimport { NvisyError } from \"@/errors.js\";\nimport { type ApiClient, createApiClient, resolveDefaults } from \"@/http.js\";\nimport {\n\tAccount,\n\tActivities,\n\tAnalytics,\n\tApiTokens,\n\tAuth,\n\tCapabilities,\n\tConnections,\n\tDetections,\n\tDocuments,\n\tInvites,\n\tMembers,\n\tNotifications,\n\tPipelines,\n\tPolicies,\n\tProviders,\n\tRedactions,\n\tReviews,\n\tStatus,\n\tSyncs,\n\tThreads,\n\tWebhooks,\n\tWorkspaces,\n} from \"@/services/index.js\";\n\n/**\n * Typed openapi-fetch client for the Nvisy API. Exposed via {@link Nvisy.api}\n * for advanced use cases requiring direct API access.\n */\nexport type { ApiClient } from \"@/http.js\";\n\n/**\n * Main client class for interacting with the Nvisy document processing API.\n *\n * @example\n * ```typescript\n * const nvisy = new Nvisy({ apiToken: \"your-api-token\" });\n * const account = await nvisy.account.getAccount();\n * const workspaces = await nvisy.workspaces.listWorkspaces();\n * ```\n */\nexport class Nvisy {\n\t/** The config this client was built from (for {@link withApiToken}). @internal */\n\treadonly #config: NvisyConfig;\n\n\t/** The resolved base URL. @internal */\n\treadonly #baseUrl: string;\n\n\t/**\n\t * The underlying openapi-fetch client instance.\n\t * @internal\n\t */\n\treadonly #api: ApiClient;\n\n\t/**\n\t * Creates a new authenticated Nvisy client.\n\t *\n\t * Requires an `apiToken` (sent as `Authorization: Bearer <token>`). For the\n\t * pre-auth surface (login / signup / OIDC start, auth capabilities, health),\n\t * use {@link NvisyGuest} from `@nvisy/sdk/guest`.\n\t *\n\t * @param config - Configuration options with a required `apiToken`\n\t * @throws {NvisyError} If the API token is missing or invalid\n\t *\n\t * @example\n\t * ```typescript\n\t * const nvisy = new Nvisy({ apiToken: \"your-api-token\" });\n\t * const account = await nvisy.account.getAccount();\n\t * ```\n\t */\n\tconstructor(config: NvisyConfig) {\n\t\tthis.#config = config;\n\t\tconst resolved = resolveDefaults(config);\n\t\tthis.#baseUrl = resolved.baseUrl;\n\t\tthis.#api = createApiClient({\n\t\t\tapiToken: this.#validateApiToken(config.apiToken),\n\t\t\tcredentials: config.credentials,\n\t\t\tfetch: config.fetch,\n\t\t\t...resolved,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an API token format.\n\t *\n\t * @param apiToken - The API token to validate\n\t * @returns The trimmed API token if valid\n\t * @throws {NvisyError} If the API token is invalid\n\t * @internal\n\t */\n\t#validateApiToken(apiToken: string): string {\n\t\tif (typeof apiToken !== \"string\" || apiToken.trim().length === 0) {\n\t\t\tthrow new NvisyError(\"API token must be a non-empty string\");\n\t\t}\n\n\t\tconst trimmedToken = apiToken.trim();\n\t\tif (trimmedToken.length < 10) {\n\t\t\tthrow new NvisyError(\"API token must be at least 10 characters\");\n\t\t}\n\n\t\tif (!/^[a-zA-Z0-9_.-]+$/.test(trimmedToken)) {\n\t\t\tthrow new NvisyError(\"API token contains invalid characters\");\n\t\t}\n\n\t\treturn trimmedToken;\n\t}\n\n\t/**\n\t * Creates a new client with a different API token.\n\t *\n\t * Returns a new client instance with the new token. The original client\n\t * remains unchanged. All other configuration (base URL, headers, etc.)\n\t * is preserved in the new client.\n\t *\n\t * @param apiToken - The new API token\n\t * @returns A new Nvisy instance with the new token\n\t * @throws {NvisyError} If the API token is invalid\n\t *\n\t * @example\n\t * ```typescript\n\t * const nvisy = new Nvisy({ apiToken: \"original-token\" });\n\t * const newNvisy = nvisy.withApiToken(\"new-token\");\n\t *\n\t * // newNvisy uses the new token\n\t * // nvisy still uses the original token\n\t * ```\n\t */\n\twithApiToken(apiToken: string): Nvisy {\n\t\treturn new Nvisy({ ...this.#config, apiToken });\n\t}\n\n\t/**\n\t * The base URL used for API requests.\n\t *\n\t * @returns The configured base URL\n\t */\n\tget baseUrl(): string {\n\t\treturn this.#baseUrl;\n\t}\n\n\t/**\n\t * The underlying openapi-fetch client for direct API access.\n\t *\n\t * Use this for advanced scenarios where you need direct access to the\n\t * HTTP client, such as calling endpoints not covered by the service classes.\n\t *\n\t * @returns The configured ApiClient instance\n\t */\n\tget api(): ApiClient {\n\t\treturn this.#api;\n\t}\n\n\t/**\n\t * Service for authenticated auth operations (logout, desktop token). Pre-auth\n\t * sign-in lives on {@link NvisyGuest}.\n\t */\n\tget auth(): Auth {\n\t\treturn new Auth(this.#api);\n\t}\n\n\t/**\n\t * Service for API status and health checks.\n\t */\n\tget status(): Status {\n\t\treturn new Status(this.#api);\n\t}\n\n\t/**\n\t * Service for managing the authenticated user's account.\n\t */\n\tget account(): Account {\n\t\treturn new Account(this.#api);\n\t}\n\n\t/**\n\t * Service for viewing workspace activities.\n\t */\n\tget activities(): Activities {\n\t\treturn new Activities(this.#api);\n\t}\n\n\t/**\n\t * Service for workspace analytics.\n\t */\n\tget analytics(): Analytics {\n\t\treturn new Analytics(this.#api);\n\t}\n\n\t/**\n\t * Service for managing API tokens.\n\t */\n\tget apiTokens(): ApiTokens {\n\t\treturn new ApiTokens(this.#api);\n\t}\n\n\t/**\n\t * Service for managing connections.\n\t */\n\tget connections(): Connections {\n\t\treturn new Connections(this.#api);\n\t}\n\n\t/**\n\t * Service for document operations (upload, download, delete, review).\n\t */\n\tget documents(): Documents {\n\t\treturn new Documents(this.#api);\n\t}\n\n\t/**\n\t * Service for discussion threads and comments.\n\t */\n\tget threads(): Threads {\n\t\treturn new Threads(this.#api);\n\t}\n\n\t/**\n\t * Service for managing pipelines.\n\t */\n\tget pipelines(): Pipelines {\n\t\treturn new Pipelines(this.#api);\n\t}\n\n\t/**\n\t * Service for managing policies.\n\t */\n\tget policies(): Policies {\n\t\treturn new Policies(this.#api);\n\t}\n\n\t/**\n\t * Service for managing a workspace's inference providers.\n\t */\n\tget providers(): Providers {\n\t\treturn new Providers(this.#api);\n\t}\n\n\t/**\n\t * Service for reading the deployment's capabilities (labels, recognizers,\n\t * connectors, auth methods).\n\t */\n\tget capabilities(): Capabilities {\n\t\treturn new Capabilities(this.#api);\n\t}\n\n\t/**\n\t * Service for managing workspace invitations.\n\t */\n\tget invites(): Invites {\n\t\treturn new Invites(this.#api);\n\t}\n\n\t/**\n\t * Service for managing workspace members.\n\t */\n\tget members(): Members {\n\t\treturn new Members(this.#api);\n\t}\n\n\t/**\n\t * Service for managing notifications.\n\t */\n\tget notifications(): Notifications {\n\t\treturn new Notifications(this.#api);\n\t}\n\n\t/**\n\t * Service for pipeline detections and their redactions.\n\t */\n\tget detections(): Detections {\n\t\treturn new Detections(this.#api);\n\t}\n\n\t/**\n\t * Service for workspace redactions.\n\t */\n\tget redactions(): Redactions {\n\t\treturn new Redactions(this.#api);\n\t}\n\n\t/**\n\t * Service for document reviews (assigning documents to reviewers).\n\t */\n\tget reviews(): Reviews {\n\t\treturn new Reviews(this.#api);\n\t}\n\n\t/**\n\t * Service for managing connection syncs.\n\t */\n\tget syncs(): Syncs {\n\t\treturn new Syncs(this.#api);\n\t}\n\n\t/**\n\t * Service for managing webhooks.\n\t */\n\tget webhooks(): Webhooks {\n\t\treturn new Webhooks(this.#api);\n\t}\n\n\t/**\n\t * Service for managing workspaces.\n\t */\n\tget workspaces(): Workspaces {\n\t\treturn new Workspaces(this.#api);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2DA,IAAa,QAAb,MAAa,MAAM;;CAElB,AAAS;;CAGT,AAAS;;;;;CAMT,AAAS;;;;;;;;;;;;;;;;;CAkBT,YAAY,QAAqB;EAChC,KAAK,UAAU;EACf,MAAM,WAAW,gBAAgB,MAAM;EACvC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AO,IAAI,QAAQ,KAAK,IAAI;CAC7B;;;;CAKA,IAAI,YAAuB;EAC1B,OAAO,IAAI,UAAU,KAAK,IAAI;CAC/B;;;;CAKA,IAAI,WAAqB;EACxB,OAAO,IAAI,SAAS,KAAK,IAAI;CAC9B;;;;CAKA,IAAI,YAAuB;EAC1B,OAAO,IAAI,UAAU,KAAK,IAAI;CAC/B;;;;;CAMA,IAAI,eAA6B;EAChC,OAAO,IAAI,aAAa,KAAK,IAAI;CAClC;;;;CAKA,IAAI,UAAmB;EACtB,OAAO,IAAI,QAAQ,KAAK,IAAI;CAC7B;;;;CAKA,IAAI,UAAmB;EACtB,OAAO,IAAI,QAAQ,KAAK,IAAI;CAC7B;;;;CAKA,IAAI,gBAA+B;EAClC,OAAO,IAAI,cAAc,KAAK,IAAI;CACnC;;;;CAKA,IAAI,aAAyB;EAC5B,OAAO,IAAI,WAAW,KAAK,IAAI;CAChC;;;;CAKA,IAAI,aAAyB;EAC5B,OAAO,IAAI,WAAW,KAAK,IAAI;CAChC;;;;CAKA,IAAI,UAAmB;EACtB,OAAO,IAAI,QAAQ,KAAK,IAAI;CAC7B;;;;CAKA,IAAI,QAAe;EAClB,OAAO,IAAI,MAAM,KAAK,IAAI;CAC3B;;;;CAKA,IAAI,WAAqB;EACxB,OAAO,IAAI,SAAS,KAAK,IAAI;CAC9B;;;;CAKA,IAAI,aAAyB;EAC5B,OAAO,IAAI,WAAW,KAAK,IAAI;CAChC;AACD"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as Activities, S as Analytics, _ as Detections, a as
|
|
2
|
-
export { Account, Activities, Analytics, ApiTokens, Auth, Capabilities, Connections, Detections, Documents, Invites, Members, Notifications, Pipelines, Policies, Providers, Redactions, Reviews, Status, Syncs, Threads, Webhooks, Workspaces };
|
|
1
|
+
import { C as Activities, S as Analytics, _ as Detections, a as Status, b as Auth, c as Providers, d as Notifications, f as Members, g as Documents, h as GuestAuth, i as Syncs, l as Policies, m as GuestCapabilities, n as Webhooks, o as Reviews, p as Invites, r as Threads, s as Redactions, t as Workspaces, u as Pipelines, v as Connections, w as Account, x as ApiTokens, y as Capabilities } from "../index-DFbHT_eq.js";
|
|
2
|
+
export { Account, Activities, Analytics, ApiTokens, Auth, Capabilities, Connections, Detections, Documents, GuestAuth, GuestCapabilities, Invites, Members, Notifications, Pipelines, Policies, Providers, Redactions, Reviews, Status, Syncs, Threads, Webhooks, Workspaces };
|
package/dist/services/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as
|
|
1
|
+
import { C as Activities, S as Analytics, _ as Detections, a as Status, b as Auth, c as Providers, d as Notifications, f as Members, g as Documents, h as GuestAuth, i as Syncs, l as Policies, m as GuestCapabilities, n as Webhooks, o as Reviews, p as Invites, r as Threads, s as Redactions, t as Workspaces, u as Pipelines, v as Connections, w as Account, x as ApiTokens, y as Capabilities } from "../services-BMmcawiT.js";
|
|
2
2
|
|
|
3
|
-
export { Account, Activities, Analytics, ApiTokens, Auth, Capabilities, Connections, Detections, Documents, Invites, Members, Notifications, Pipelines, Policies, Providers, Redactions, Reviews, Status, Syncs, Threads, Webhooks, Workspaces };
|
|
3
|
+
export { Account, Activities, Analytics, ApiTokens, Auth, Capabilities, Connections, Detections, Documents, GuestAuth, GuestCapabilities, Invites, Members, Notifications, Pipelines, Policies, Providers, Redactions, Reviews, Status, Syncs, Threads, Webhooks, Workspaces };
|
|
@@ -309,7 +309,9 @@ var ApiTokens = class {
|
|
|
309
309
|
//#endregion
|
|
310
310
|
//#region src/services/auth.ts
|
|
311
311
|
/**
|
|
312
|
-
*
|
|
312
|
+
* Authenticated auth operations: ending the current session and minting a
|
|
313
|
+
* desktop token from it. Pre-auth sign-in (login / signup / OIDC start) lives on
|
|
314
|
+
* the guest client ({@link NvisyGuest}).
|
|
313
315
|
*/
|
|
314
316
|
var Auth = class {
|
|
315
317
|
#api;
|
|
@@ -317,34 +319,6 @@ var Auth = class {
|
|
|
317
319
|
this.#api = api;
|
|
318
320
|
}
|
|
319
321
|
/**
|
|
320
|
-
* Login with email and password, starting a browser session.
|
|
321
|
-
*
|
|
322
|
-
* Sets HttpOnly session and CSRF cookies; returns no body. Programmatic
|
|
323
|
-
* clients should instead create an API token via {@link ApiTokens} and pass
|
|
324
|
-
* it as `apiToken` when constructing the client.
|
|
325
|
-
*
|
|
326
|
-
* @param credentials - Login credentials
|
|
327
|
-
* @returns Promise that resolves once the session is started
|
|
328
|
-
* @throws {ApiError} if the request fails
|
|
329
|
-
*/
|
|
330
|
-
async loginAccount(credentials) {
|
|
331
|
-
await this.#api.POST("/auth/login", { body: credentials });
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Sign up a new account, starting a browser session.
|
|
335
|
-
*
|
|
336
|
-
* Sets HttpOnly session and CSRF cookies; returns no body. Programmatic
|
|
337
|
-
* clients should instead create an API token via {@link ApiTokens} and pass
|
|
338
|
-
* it as `apiToken` when constructing the client.
|
|
339
|
-
*
|
|
340
|
-
* @param credentials - Signup details
|
|
341
|
-
* @returns Promise that resolves once the session is started
|
|
342
|
-
* @throws {ApiError} if the request fails
|
|
343
|
-
*/
|
|
344
|
-
async signupAccount(credentials) {
|
|
345
|
-
await this.#api.POST("/auth/signup", { body: credentials });
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
322
|
* Logout, invalidating the current session and clearing its cookies.
|
|
349
323
|
* @returns Promise that resolves when logout is complete
|
|
350
324
|
* @throws {ApiError} if the request fails
|
|
@@ -353,25 +327,6 @@ var Auth = class {
|
|
|
353
327
|
await this.#api.POST("/auth/logout");
|
|
354
328
|
}
|
|
355
329
|
/**
|
|
356
|
-
* Begin an OpenID Connect sign-in with a provider.
|
|
357
|
-
*
|
|
358
|
-
* Returns the provider authorize URL to redirect the user to; on consent the
|
|
359
|
-
* provider redirects to the callback, which signs the user in. Also available
|
|
360
|
-
* as the standalone `startOidcSignIn` for use without a client.
|
|
361
|
-
*
|
|
362
|
-
* @param provider - The identity provider to sign in with
|
|
363
|
-
* @param query - Optional frontend URL to return to once done
|
|
364
|
-
* @returns Promise that resolves with the provider authorize URL
|
|
365
|
-
* @throws {ApiError} if the request fails
|
|
366
|
-
*/
|
|
367
|
-
async startOidcSignIn(provider, query) {
|
|
368
|
-
const { data } = await this.#api.GET("/auth/{provider}/start", { params: {
|
|
369
|
-
path: { provider },
|
|
370
|
-
query
|
|
371
|
-
} });
|
|
372
|
-
return data;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
330
|
* Mint a long-lived native-app token for a desktop app.
|
|
376
331
|
*
|
|
377
332
|
* Requires an active browser session (the desktop login completes in the
|
|
@@ -1045,6 +1000,94 @@ var Documents = class {
|
|
|
1045
1000
|
}
|
|
1046
1001
|
};
|
|
1047
1002
|
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region src/services/guest-auth.ts
|
|
1005
|
+
/**
|
|
1006
|
+
* Pre-auth authentication operations, reachable without an API token: starting
|
|
1007
|
+
* a browser session (login / signup) and beginning an OIDC sign-in. Exposed on
|
|
1008
|
+
* the guest client ({@link NvisyGuest}).
|
|
1009
|
+
*/
|
|
1010
|
+
var GuestAuth = class {
|
|
1011
|
+
#api;
|
|
1012
|
+
constructor(api) {
|
|
1013
|
+
this.#api = api;
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Login with email and password, starting a browser session.
|
|
1017
|
+
*
|
|
1018
|
+
* Sets HttpOnly session and CSRF cookies; returns no body. For a programmatic
|
|
1019
|
+
* client, create an API token instead and pass it as `apiToken` when
|
|
1020
|
+
* constructing a {@link Nvisy} client.
|
|
1021
|
+
*
|
|
1022
|
+
* @param credentials - Login credentials
|
|
1023
|
+
* @returns Promise that resolves once the session is started
|
|
1024
|
+
* @throws {ApiError} if the request fails
|
|
1025
|
+
*/
|
|
1026
|
+
async loginAccount(credentials) {
|
|
1027
|
+
await this.#api.POST("/auth/login", { body: credentials });
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Sign up a new account, starting a browser session.
|
|
1031
|
+
*
|
|
1032
|
+
* Sets HttpOnly session and CSRF cookies; returns no body. For a programmatic
|
|
1033
|
+
* client, create an API token instead and pass it as `apiToken` when
|
|
1034
|
+
* constructing a {@link Nvisy} client.
|
|
1035
|
+
*
|
|
1036
|
+
* @param credentials - Signup details
|
|
1037
|
+
* @returns Promise that resolves once the session is started
|
|
1038
|
+
* @throws {ApiError} if the request fails
|
|
1039
|
+
*/
|
|
1040
|
+
async signupAccount(credentials) {
|
|
1041
|
+
await this.#api.POST("/auth/signup", { body: credentials });
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Begin an OpenID Connect sign-in with a provider.
|
|
1045
|
+
*
|
|
1046
|
+
* Returns the provider authorize URL to redirect the user to; on consent the
|
|
1047
|
+
* provider redirects to the callback, which signs the user in.
|
|
1048
|
+
*
|
|
1049
|
+
* @param provider - The identity provider to sign in with
|
|
1050
|
+
* @param query - Optional frontend URL to return to once done
|
|
1051
|
+
* @returns Promise that resolves with the provider authorize URL
|
|
1052
|
+
* @throws {ApiError} if the request fails
|
|
1053
|
+
*/
|
|
1054
|
+
async startOidcSignIn(provider, query) {
|
|
1055
|
+
const { data } = await this.#api.GET("/auth/{provider}/start", { params: {
|
|
1056
|
+
path: { provider },
|
|
1057
|
+
query
|
|
1058
|
+
} });
|
|
1059
|
+
return data;
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
|
|
1063
|
+
//#endregion
|
|
1064
|
+
//#region src/services/guest-capabilities.ts
|
|
1065
|
+
/**
|
|
1066
|
+
* The pre-auth subset of the deployment's capabilities: the sign-in methods it
|
|
1067
|
+
* offers. The label / recognizer / connector capability reads require an
|
|
1068
|
+
* authenticated client and live on {@link Capabilities}.
|
|
1069
|
+
*/
|
|
1070
|
+
var GuestCapabilities = class {
|
|
1071
|
+
#api;
|
|
1072
|
+
constructor(api) {
|
|
1073
|
+
this.#api = api;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Get the deployment's available sign-in methods.
|
|
1077
|
+
*
|
|
1078
|
+
* Public: reports whether password sign-in is enabled and which OIDC
|
|
1079
|
+
* providers are configured, so a login screen can render the right buttons
|
|
1080
|
+
* before anyone signs in.
|
|
1081
|
+
*
|
|
1082
|
+
* @returns Promise that resolves with the auth capabilities.
|
|
1083
|
+
* @throws {ApiError} if the request fails
|
|
1084
|
+
*/
|
|
1085
|
+
async getAuthCapabilities() {
|
|
1086
|
+
const { data } = await this.#api.GET("/capabilities/auth");
|
|
1087
|
+
return data;
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1048
1091
|
//#endregion
|
|
1049
1092
|
//#region src/services/invites.ts
|
|
1050
1093
|
/**
|
|
@@ -1684,21 +1727,35 @@ var Reviews = class {
|
|
|
1684
1727
|
return data;
|
|
1685
1728
|
}
|
|
1686
1729
|
/**
|
|
1687
|
-
* Assign
|
|
1730
|
+
* Assign a reviewer to a review (idempotent).
|
|
1688
1731
|
* @param workspaceId - Workspace id
|
|
1689
1732
|
* @param reviewId - Review ID
|
|
1690
|
-
* @param
|
|
1733
|
+
* @param accountId - Account id of the reviewer to assign
|
|
1691
1734
|
* @returns Promise that resolves with the updated review
|
|
1692
1735
|
* @throws {ApiError} if the request fails
|
|
1693
1736
|
*/
|
|
1694
|
-
async
|
|
1695
|
-
const { data } = await this.#api.
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1737
|
+
async assignReviewer(workspaceId, reviewId, accountId) {
|
|
1738
|
+
const { data } = await this.#api.POST("/workspaces/{workspaceId}/reviews/{reviewId}/assignees/{accountId}", { params: { path: {
|
|
1739
|
+
workspaceId,
|
|
1740
|
+
reviewId,
|
|
1741
|
+
accountId
|
|
1742
|
+
} } });
|
|
1743
|
+
return data;
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Remove a reviewer from a review.
|
|
1747
|
+
* @param workspaceId - Workspace id
|
|
1748
|
+
* @param reviewId - Review ID
|
|
1749
|
+
* @param accountId - Account id of the reviewer to remove
|
|
1750
|
+
* @returns Promise that resolves with the updated review
|
|
1751
|
+
* @throws {ApiError} if the request fails
|
|
1752
|
+
*/
|
|
1753
|
+
async unassignReviewer(workspaceId, reviewId, accountId) {
|
|
1754
|
+
const { data } = await this.#api.DELETE("/workspaces/{workspaceId}/reviews/{reviewId}/assignees/{accountId}", { params: { path: {
|
|
1755
|
+
workspaceId,
|
|
1756
|
+
reviewId,
|
|
1757
|
+
accountId
|
|
1758
|
+
} } });
|
|
1702
1759
|
return data;
|
|
1703
1760
|
}
|
|
1704
1761
|
/**
|
|
@@ -2311,5 +2368,5 @@ var Workspaces = class {
|
|
|
2311
2368
|
};
|
|
2312
2369
|
|
|
2313
2370
|
//#endregion
|
|
2314
|
-
export {
|
|
2315
|
-
//# sourceMappingURL=services-
|
|
2371
|
+
export { Activities as C, Analytics as S, Detections as _, Status as a, Auth as b, Providers as c, Notifications as d, Members as f, Documents as g, GuestAuth as h, Syncs as i, Policies as l, GuestCapabilities as m, Webhooks as n, Reviews as o, Invites as p, Threads as r, Redactions as s, Workspaces as t, Pipelines as u, Connections as v, Account as w, ApiTokens as x, Capabilities as y };
|
|
2372
|
+
//# sourceMappingURL=services-BMmcawiT.js.map
|