@nvisy/sdk 0.53.0 → 0.55.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 +50 -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 +35 -0
- package/dist/guest/index.d.ts.map +1 -0
- package/dist/guest/index.js +59 -0
- package/dist/guest/index.js.map +1 -0
- package/dist/http-BRaKBzAA.js +128 -0
- package/dist/http-BRaKBzAA.js.map +1 -0
- package/dist/{client-DywPcOzJ.d.ts → index-CuKzO8Ly.d.ts} +357 -216
- package/dist/index-CuKzO8Ly.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 +4 -5
- package/dist/index.js +34 -120
- 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/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,53 @@ and this project adheres to
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.55.0] - 2026-09-15
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **Breaking:** the authenticated `Nvisy` client now authenticates explicitly
|
|
16
|
+
with either `apiToken` or `session: true` (mutually exclusive at the type
|
|
17
|
+
level). `session: true` uses the browser cookie session established by the
|
|
18
|
+
guest client's login / signup and sends credentialed requests automatically
|
|
19
|
+
(`credentials: "include"`). This restores driving the full authenticated API
|
|
20
|
+
from a browser session, which the 0.54.0 apiToken-required change had removed
|
|
21
|
+
- **Breaking:** the client config types are renamed for consistency:
|
|
22
|
+
`ClientConfig` / `NvisyConfig` → `NvisyOptions` (the authenticated client) and
|
|
23
|
+
`NvisyGuestOptions` (the guest client, transport-only). The `GuestConfig` alias
|
|
24
|
+
is removed — `NvisyGuest` takes `NvisyGuestOptions`
|
|
25
|
+
|
|
26
|
+
## [0.54.0] - 2026-09-15
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- `NvisyGuest`, a dedicated pre-auth client exported from `@nvisy/sdk/guest`,
|
|
31
|
+
for the endpoints that work without an API token: `guest.auth`
|
|
32
|
+
(`loginAccount`, `signupAccount`, `startOidcSignIn`), `guest.capabilities`
|
|
33
|
+
(`getAuthCapabilities`), and `guest.health` (`checkHealth`, `checkLiveness`,
|
|
34
|
+
`checkReadiness`). This fixes the auth capabilities and health probes being
|
|
35
|
+
reachable only through the authenticated client
|
|
36
|
+
- `reviews.unassignReviewer(workspaceId, reviewId, accountId)` removes a
|
|
37
|
+
reviewer from a review
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- Regenerated the API schema against the updated platform handlers
|
|
42
|
+
- **Breaking:** review assignment is now a path-addressed subcollection.
|
|
43
|
+
`reviews.assignReview(ws, reviewId, body)` is replaced by
|
|
44
|
+
`reviews.assignReviewer(ws, reviewId, accountId)`; the `AssignWorkspaceReview`
|
|
45
|
+
datatype is removed
|
|
46
|
+
- **Breaking:** the `Nvisy` client again requires an `apiToken`. Pre-auth flows
|
|
47
|
+
(login / signup / OIDC start, auth capabilities, health) moved to `NvisyGuest`.
|
|
48
|
+
Sign-in methods (`loginAccount`, `signupAccount`, `startOidcSignIn`) are no
|
|
49
|
+
longer on `nvisy.auth`; `nvisy.auth` now covers `logoutAccount` and
|
|
50
|
+
`mintDesktopToken`
|
|
51
|
+
|
|
52
|
+
### Removed
|
|
53
|
+
|
|
54
|
+
- **Breaking:** the `@nvisy/sdk/standalone` entry and its free functions
|
|
55
|
+
(`login`, `signup`, `startOidcSignIn`, `getAuthCapabilities`, `checkHealth`).
|
|
56
|
+
Use `NvisyGuest` from `@nvisy/sdk/guest` instead
|
|
57
|
+
|
|
11
58
|
## [0.53.0] - 2026-09-15
|
|
12
59
|
|
|
13
60
|
### Added
|
|
@@ -1154,7 +1201,9 @@ redaction an independent resource. This release renames the SDK to match.
|
|
|
1154
1201
|
- Network error handling for timeouts, DNS resolution, and connection issues
|
|
1155
1202
|
- Configuration validation with detailed error messages
|
|
1156
1203
|
|
|
1157
|
-
[Unreleased]: https://github.com/nvisycom/sdk-ts/compare/v0.
|
|
1204
|
+
[Unreleased]: https://github.com/nvisycom/sdk-ts/compare/v0.55.0...HEAD
|
|
1205
|
+
[0.55.0]: https://github.com/nvisycom/sdk-ts/compare/v0.54.0...v0.55.0
|
|
1206
|
+
[0.54.0]: https://github.com/nvisycom/sdk-ts/compare/v0.53.0...v0.54.0
|
|
1158
1207
|
[0.53.0]: https://github.com/nvisycom/sdk-ts/compare/v0.52.0...v0.53.0
|
|
1159
1208
|
[0.52.0]: https://github.com/nvisycom/sdk-ts/compare/v0.51.0...v0.52.0
|
|
1160
1209
|
[0.51.0]: https://github.com/nvisycom/sdk-ts/compare/v0.50.0...v0.51.0
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export type { Account, AccountApiToken, AccountApiTokenPage, AccountApiTokenWithJwt, AccountDesktopToken, AccountIdentities, AccountIdentity, AccountMarkedReadStatus, AccountNotification, AccountNotificationPage, AccountRef, AccountUnreadStatus, ActivityPayload, ActivityType, ApiTokenType, ArtifactSet,
|
|
1
|
+
import { $ as WorkspaceProvider, $a as AccountApiTokenPage, $i as PatternEvent, $n as DetectionMetadata, $r as Signup, $t as AccountNotification, A as WorkspaceThreadEvent, Aa as TextCoord, Ai as EditSet, An as WorkspaceInviteCode, Ao as ReviewActivityParams, Ar as SyncScheduleInput, At as Predicate, B as CreateWorkspaceReview, Ba as TextRefinement, Bi as ImageHint, Bn as DeleteWorkspaceDocuments, Bo as AccountIdentities, Br as WorkspaceConnectionsQuery, Bt as WorkspacePolicySummary, C as RenameWorkspaceThread, Ca as TabularPattern, Ci as Conflict, Cn as InviteExpiration, Co as DocumentActivityParams, Cr as OAuthTokens, Ct as PciDssPart, D as WorkspaceThread, Da as TextAuditEvent, Di as Dimensions, Dn as ListWorkspaceInvites, Do as PolicyActivityParams, Dr as StorageConfig, Dt as PolicyKind, E as WorkspaceComment, Ea as TextAdd, Ei as Deduplication, En as InviteStatus, Eo as PipelineActivityParams, Er as StartFileServiceOAuth, Et as PolicyDraft, F as Language, Fa as TextLocation, Fi as ImageAuditKind, Fn as HealthStatus, Fo as WorkspaceActivityExportOptions, Fr as WorkspaceConnection, Ft as TextRedaction, G as WorkspaceReviewPage, Ga as LayoutBlock, Gi as ImagePattern, Gn as ModalityToken, Go as OidcStartResponse, Gr as ConnectorCapabilities, Gt as PipelineTriggerType, H as WorkspaceReview, Ha as TimeSpan, Hi as ImageManual, Hn as DocumentKind, Ho as AccountRef, Hr as WorkspacePickerTokenRequest, Ht as CreateWorkspacePipeline, I as LanguageProvenance, Ia as TextManual, Ii as ImageAuditLog, In as DateWindow, Io as WorkspaceActivityFilterQuery, Ir as WorkspaceConnectionPage, It as UpdateWorkspacePolicy, J as InferenceConfig, Ja as Tokens, Ji as LeakProfile, Jn as WorkspaceDocument, Jo as UpdateAccount, Jr as RecognizerCatalog, Jt as WorkspacePipelineFilter, K as WorkspaceReviewsQuery, Ka as LayoutWord, Ki as ImageRefinement, Kn as UpdateWorkspaceDocument, Ko as PublicAccount, Kr as FileProviders, Kt as UpdateWorkspacePipeline, L as LanguageSpan, La as TextMetadata, Li as ImageData, Ln as ExportFormat, Lo as WorkspaceActivityPage, Lr as WorkspaceConnectionSync, Lt as Waveform, M as WorkspaceThreadsQuery, Ma as TextEdit, Mi as FreeformAttribution, Mn as WorkspaceInviteSent, Mo as ThreadCommentActivityParams, Mr as SyncTriggerType, Mt as TabularRedaction, N as Confidence, Na as TextEntity, Ni as ImageAdd, Nn as ComponentHealth, No as WebhookActivityParams, Nr as UnauthenticatedProvider, Nt as TemplateOrigin, O as WorkspaceThreadEntry, Oa as TextAuditKind, Oi as DocumentContext, On as ReplyWorkspaceInvite, Oo as ProviderActivityParams, Or as SyncDeletionPolicy, Ot as PolicyRule, P as CountryCode, Pa as TextHint, Pi as ImageAuditEvent, Pn as Health, Po as WorkspaceActivity, Pr as UpdateWorkspaceConnection, Pt as TerminalFallback, Q as UpdateWorkspaceProvider, Qa as AccountApiToken, Qi as OperatorId, Qn as DetectionId, Qr as Login, Qt as AccountMarkedReadStatus, R as Languages, Ra as TextModel, Ri as ImageEdit, Rn as ExportQuery, Ro as WorkspaceActivityParams, Rr as WorkspaceConnectionSyncPage, Rt as WorkspacePoliciesQuery, S as OpenWorkspaceThread, Sa as TabularModel, Si as CodecParams, Sn as GenerateWorkspaceInviteCode, So as DetectionActivityParams, Sr as OAuthStartResponse, St as ModalityRedactions, T as UpdateWorkspaceComment, Ta as TabularRetag, Ti as DecodedSpan, Tn as InviteSortField, To as MemberActivityParams, Tr as S3Credentials, Tt as Policy, U as WorkspaceReviewEvent, Ua as ArtifactSet, Ui as ImageMetadata, Un as FormatToken, Uo as Handle, Ur as WorkspaceSyncSchedule, Ut as PipelineDefinition, V as ReviewStatus, Va as TextRetag, Vi as ImageLocation, Vn as DocumentHash, Vo as AccountIdentity, Vr as WorkspacePickerToken, Vt as WorkspacePolicySummaryPage, W as WorkspaceReviewEventPage, Wa as Layout, Wi as ImageModel, Wn as ListWorkspaceDocuments, Wo as IdentityProvider, Wr as AuthCapabilities, Wt as PipelineStatus, X as ProviderId, Xa as TranscriptWord, Xi as MetadataEvent, Xn as CreateAdhocWorkspaceDetection, Xr as AccountDesktopToken, Xt as WorkspacePipelineSummaryPage, Y as ProviderConfig, Ya as TranscriptSegment, Yi as ManualIntent, Yn as WorkspaceDocumentPage, Yr as RegisteredRecognizer, Yt as WorkspacePipelineSummary, Z as ProviderType, Za as Transcription, Zi as ModelEvent, Zn as CreateWorkspaceDetection, Zr as DesktopTokenRequest, Zt as CursorPagination, _ as WorkspaceWebhook, _a as TabularEntity, _i as AuditHash, _n as UpdateWorkspaceMember, _o as WorkspaceStorageKindEntry, _r as FileServiceConfig, _t as LabelLocale, a as RetentionSettings, aa as Redaction, ai as AudioData, an as DetectionCompletedParams, ao as ModelUsage, ar as WorkspaceDetectionPage, at as ConfidenceThreshold, b as WorkspaceWebhookResult, ba as TabularManual, bi as Category, bn as CreateWorkspaceInvite, bo as ActivityType, br as ImportWorkspaceFiles, bt as LanguageTag, c as WorkspacePage, ca as Selection, ci as AudioHint, cn as NotificationEvent, co as Usage, cr as WorkspaceRedactionResult, ct as DateGranularity, d as CreateWorkspaceWebhook, da as Suppress, di as AudioMetadata, dn as ReviewAssignedParams, do as WorkspaceDetectionAnalytics, dr as AzureCredentials, dt as GdprSensitiveScope, ea as Point, ei as Attribution, en as AccountNotificationPage, eo as AccountApiTokenWithJwt, er as DetectionStatus, et as WorkspaceProviderPage, f as TestWorkspaceWebhook, fa as TabularAdd, fi as AudioModel, fn as UnreadCountEvent, fo as WorkspaceDetectionDayEntry, fr as ConnectionConfig, ft as HipaaAccountNumbers, g as WebhookStatus, ga as TabularEdit, gi as Audit, gn as MemberSortField, go as WorkspaceStorageAnalytics, gr as ExportWorkspaceFiles, gt as LabelEntry, h as WebhookId, ha as TabularAuditLog, hi as AudioRetag, hn as ListWorkspaceMembers, ho as WorkspaceModelUsageEntry, hr as CreateWorkspaceConnection, ht as Label, i as RetentionOverride, ia as Recognition, ii as AudioAuditLog, in as ConnectionSyncFailedParams, io as UpdateAccountApiToken, ir as WorkspaceDetection, it as Color, j as WorkspaceThreadPage, ja as TextData, ji as EntityCoRef, jn as WorkspaceInvitePage, jo as ThreadActivityParams, jr as SyncStatus, jt as Sha2Algorithm, k as WorkspaceThreadEntryPage, ka as TextAuditLog, ki as Dpi, kn as WorkspaceInvite, ko as RedactionActivityParams, kr as SyncMode, kt as PolicyTemplate, l as WorkspaceRole, la as SourceRef, li as AudioLocation, ln as NotificationPayload, lo as UsageReport, lr as WorkspaceRedactionResultPage, lt as DateStyle, m as WebhookEvent, ma as TabularAuditKind, mi as AudioRefinement, mn as WorkspaceNotificationSettings, mo as WorkspaceDetectionTimeSeries, mr as ConnectionType, mt as ImageRedaction, n as RasterPolicy, na as RangeOfUint, ni as AudioAuditEvent, nn as CommentMentionedParams, no as CreateAccountApiToken, nr as RedactWorkspaceDetection, nt as AudioRedaction, o as UpdateWorkspace, oa as Report, oi as AudioEdit, on as DetectionFailedParams, oo as RecognizerId, or as WorkspaceDetectionsQuery, ot as CreateWorkspacePolicy, p as UpdateWorkspaceWebhook, pa as TabularAuditEvent, pi as AudioPattern, pn as UpdateWorkspaceNotificationSettings, po as WorkspaceDetectionStatusEntry, pr as ConnectionId, pt as HipaaDeidMethod, q as CreateWorkspaceProvider, qa as Token, qi as ImageRetag, qn as WorkspaceDeletedDocuments, qo as SetPassword, qr as LabelCatalog, qt as WorkspacePipeline, r as Retention, ra as RasterMode, ri as AudioAuditKind, rn as ConnectionSyncCompletedParams, ro as TokenExpiration, rr as RedactionId, rt as ClampBucket, s as Workspace, sa as RuleMatch, si as AudioEntity, sn as MemberJoinedParams, so as TokenCounts, sr as WorkspacePipelineDetectionsQuery, st as CustomMatcher, t as CreateWorkspace, ta as Polygon, ti as AudioAdd, tn as AccountUnreadStatus, to as ApiTokenType, tr as DetectionStatusEvent, tt as WorkspaceProvidersQuery, u as WorkspaceSettings, ua as SourceSpan, ui as AudioManual, un as RedactionCreatedParams, uo as WorkspaceAnalytics, ur as AuthenticatedProvider, ut as GdprArticle9Treatment, v as WorkspaceWebhookCreated, va as TabularHint, vi as BoundingBox, vn as WorkspaceMember, vo as WorkspaceUsageAnalytics, vr as FileServiceProvider, vt as LabelRef, w as ThreadEventKind, wa as TabularRefinement, wi as Contested, wn as InvitePreview, wo as InviteActivityParams, wr as PickedFile, wt as PciPanRender, x as CreateWorkspaceComment, xa as TabularMetadata, xi as CitedAttribution, xn as Direction, xo as ConnectionActivityParams, xr as LlmConfig, xt as LocalizedText, y as WorkspaceWebhookPage, ya as TabularLocation, yi as Calibration, yn as WorkspaceMemberPage, yo as ActivityPayload, yr as GcsCredentials, yt as LabelScope, z as ScopeMetadata, za as TextPattern, zi as ImageEntity, zn as ErrorResponse, zo as Account, zr as WorkspaceConnectionVerification, zt as WorkspacePolicy } from "../index-DzEtj1r2.js";
|
|
2
|
+
export type { Account, AccountApiToken, AccountApiTokenPage, AccountApiTokenWithJwt, AccountDesktopToken, AccountIdentities, AccountIdentity, AccountMarkedReadStatus, AccountNotification, AccountNotificationPage, AccountRef, AccountUnreadStatus, ActivityPayload, ActivityType, ApiTokenType, ArtifactSet, Attribution, AudioAdd, AudioAuditEvent, AudioAuditKind, AudioAuditLog, AudioData, AudioEdit, AudioEntity, AudioHint, AudioLocation, AudioManual, AudioMetadata, AudioModel, AudioPattern, AudioRedaction, AudioRefinement, AudioRetag, Audit, AuditHash, AuthCapabilities, AuthenticatedProvider, AzureCredentials, BoundingBox, Calibration, Category, CitedAttribution, ClampBucket, CodecParams, Color, CommentMentionedParams, ComponentHealth, Confidence, ConfidenceThreshold, Conflict, ConnectionActivityParams, ConnectionConfig, ConnectionId, ConnectionSyncCompletedParams, ConnectionSyncFailedParams, ConnectionType, ConnectorCapabilities, Contested, CountryCode, CreateAccountApiToken, CreateAdhocWorkspaceDetection, CreateWorkspace, CreateWorkspaceComment, CreateWorkspaceConnection, CreateWorkspaceDetection, CreateWorkspaceInvite, CreateWorkspacePipeline, CreateWorkspacePolicy, CreateWorkspaceProvider, CreateWorkspaceReview, CreateWorkspaceWebhook, CursorPagination, CustomMatcher, DateGranularity, DateStyle, DateWindow, DecodedSpan, Deduplication, DeleteWorkspaceDocuments, DesktopTokenRequest, DetectionActivityParams, DetectionCompletedParams, DetectionFailedParams, DetectionId, DetectionMetadata, DetectionStatus, DetectionStatusEvent, Dimensions, Direction, DocumentActivityParams, DocumentContext, DocumentHash, DocumentKind, Dpi, EditSet, EntityCoRef, ErrorResponse, ExportFormat, ExportQuery, ExportWorkspaceFiles, FileProviders, FileServiceConfig, FileServiceProvider, FormatToken, FreeformAttribution, GcsCredentials, GdprArticle9Treatment, GdprSensitiveScope, GenerateWorkspaceInviteCode, Handle, Health, HealthStatus, HipaaAccountNumbers, HipaaDeidMethod, IdentityProvider, ImageAdd, ImageAuditEvent, ImageAuditKind, ImageAuditLog, ImageData, ImageEdit, ImageEntity, ImageHint, ImageLocation, ImageManual, ImageMetadata, ImageModel, ImagePattern, ImageRedaction, ImageRefinement, ImageRetag, ImportWorkspaceFiles, InferenceConfig, InviteActivityParams, InviteExpiration, InvitePreview, InviteSortField, InviteStatus, Label, LabelCatalog, LabelEntry, LabelLocale, LabelRef, LabelScope, Language, LanguageProvenance, LanguageSpan, LanguageTag, Languages, Layout, LayoutBlock, LayoutWord, LeakProfile, ListWorkspaceDocuments, ListWorkspaceInvites, ListWorkspaceMembers, LlmConfig, LocalizedText, Login, ManualIntent, MemberActivityParams, MemberJoinedParams, MemberSortField, MetadataEvent, ModalityRedactions, ModalityToken, ModelEvent, ModelUsage, NotificationEvent, NotificationPayload, OAuthStartResponse, OAuthTokens, OidcStartResponse, OpenWorkspaceThread, OperatorId, PatternEvent, PciDssPart, PciPanRender, PickedFile, PipelineActivityParams, PipelineDefinition, PipelineStatus, PipelineTriggerType, Point, Policy, PolicyActivityParams, PolicyDraft, PolicyKind, PolicyRule, PolicyTemplate, Polygon, Predicate, ProviderActivityParams, ProviderConfig, ProviderId, ProviderType, PublicAccount, RangeOfUint, RasterMode, RasterPolicy, Recognition, RecognizerCatalog, RecognizerId, RedactWorkspaceDetection, Redaction, RedactionActivityParams, RedactionCreatedParams, RedactionId, RegisteredRecognizer, RenameWorkspaceThread, ReplyWorkspaceInvite, Report, Retention, RetentionOverride, RetentionSettings, ReviewActivityParams, ReviewAssignedParams, ReviewStatus, RuleMatch, S3Credentials, ScopeMetadata, Selection, SetPassword, Sha2Algorithm, Signup, SourceRef, SourceSpan, StartFileServiceOAuth, StorageConfig, Suppress, SyncDeletionPolicy, SyncMode, SyncScheduleInput, SyncStatus, SyncTriggerType, TabularAdd, TabularAuditEvent, TabularAuditKind, TabularAuditLog, TabularEdit, TabularEntity, TabularHint, TabularLocation, TabularManual, TabularMetadata, TabularModel, TabularPattern, TabularRedaction, TabularRefinement, TabularRetag, TemplateOrigin, TerminalFallback, TestWorkspaceWebhook, TextAdd, TextAuditEvent, TextAuditKind, TextAuditLog, TextCoord, TextData, TextEdit, TextEntity, TextHint, TextLocation, TextManual, TextMetadata, TextModel, TextPattern, TextRedaction, TextRefinement, TextRetag, ThreadActivityParams, ThreadCommentActivityParams, ThreadEventKind, TimeSpan, Token, TokenCounts, TokenExpiration, Tokens, TranscriptSegment, TranscriptWord, Transcription, UnauthenticatedProvider, UnreadCountEvent, UpdateAccount, UpdateAccountApiToken, UpdateWorkspace, UpdateWorkspaceComment, UpdateWorkspaceConnection, UpdateWorkspaceDocument, UpdateWorkspaceMember, UpdateWorkspaceNotificationSettings, UpdateWorkspacePipeline, UpdateWorkspacePolicy, UpdateWorkspaceProvider, UpdateWorkspaceWebhook, Usage, UsageReport, Waveform, WebhookActivityParams, WebhookEvent, WebhookId, WebhookStatus, Workspace, WorkspaceActivity, WorkspaceActivityExportOptions, WorkspaceActivityFilterQuery, WorkspaceActivityPage, WorkspaceActivityParams, WorkspaceAnalytics, WorkspaceComment, WorkspaceConnection, WorkspaceConnectionPage, WorkspaceConnectionSync, WorkspaceConnectionSyncPage, WorkspaceConnectionVerification, WorkspaceConnectionsQuery, WorkspaceDeletedDocuments, WorkspaceDetection, WorkspaceDetectionAnalytics, WorkspaceDetectionDayEntry, WorkspaceDetectionPage, WorkspaceDetectionStatusEntry, WorkspaceDetectionTimeSeries, WorkspaceDetectionsQuery, WorkspaceDocument, WorkspaceDocumentPage, WorkspaceInvite, WorkspaceInviteCode, WorkspaceInvitePage, WorkspaceInviteSent, WorkspaceMember, WorkspaceMemberPage, WorkspaceModelUsageEntry, WorkspaceNotificationSettings, WorkspacePage, WorkspacePickerToken, WorkspacePickerTokenRequest, WorkspacePipeline, WorkspacePipelineDetectionsQuery, WorkspacePipelineFilter, WorkspacePipelineSummary, WorkspacePipelineSummaryPage, WorkspacePoliciesQuery, WorkspacePolicy, WorkspacePolicySummary, WorkspacePolicySummaryPage, WorkspaceProvider, WorkspaceProviderPage, WorkspaceProvidersQuery, WorkspaceRedactionResult, WorkspaceRedactionResultPage, WorkspaceReview, WorkspaceReviewEvent, WorkspaceReviewEventPage, WorkspaceReviewPage, WorkspaceReviewsQuery, WorkspaceRole, WorkspaceSettings, WorkspaceStorageAnalytics, WorkspaceStorageKindEntry, WorkspaceSyncSchedule, WorkspaceThread, WorkspaceThreadEntry, WorkspaceThreadEntryPage, WorkspaceThreadEvent, WorkspaceThreadPage, WorkspaceThreadsQuery, WorkspaceUsageAnalytics, WorkspaceWebhook, WorkspaceWebhookCreated, WorkspaceWebhookPage, WorkspaceWebhookResult };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { zn as ErrorResponse } from "./index-DzEtj1r2.js";
|
|
2
2
|
//#region src/errors.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Base error class for all Nvisy SDK errors.
|
|
@@ -109,4 +109,4 @@ declare class NvisyApiError extends NvisyError implements ErrorResponse {
|
|
|
109
109
|
}
|
|
110
110
|
//#endregion
|
|
111
111
|
export { NvisyError as n, NvisyApiError as t };
|
|
112
|
-
//# sourceMappingURL=errors-
|
|
112
|
+
//# sourceMappingURL=errors-DShmkdjS.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-DShmkdjS.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAgCa,mBAAmB;;;;WAIf;;;;;;EAOJ,YAAA;;;;;;;;;;;;;;;;;;;;;;;;cA4BA,sBAAsB,sBAAsB;;;;WAIxC;;;;WAKA;;;;WAKA;;;;;;;EAQJ,YAAA,UAAU,eAAe;;;;;;;;;EAerC;;;;;;;;;EAYA;;;;;;;;;EAYA;;;;;;;;EAeA,UAAU"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { E as ApiClient, O as NvisyGuestOptions, a as Status, h as GuestAuth, m as GuestCapabilities } from "../index-CuKzO8Ly.js";
|
|
2
|
+
//#region src/guest/client.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Pre-auth Nvisy client. Wraps a token-less {@link ApiClient} and exposes the
|
|
5
|
+
* public surface: {@link GuestAuth}, {@link GuestCapabilities}, and
|
|
6
|
+
* {@link Status}. Configured with the shared {@link NvisyGuestOptions} (no auth); a
|
|
7
|
+
* guest client never sends a token. Pass `credentials: "include"` to send the
|
|
8
|
+
* session cookies set by login / signup on a cross-origin app.
|
|
9
|
+
*/
|
|
10
|
+
export declare class NvisyGuest {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new pre-auth Nvisy client (no API token).
|
|
14
|
+
*
|
|
15
|
+
* @param config - Optional configuration (baseUrl, credentials, headers,
|
|
16
|
+
* userAgent, fetch)
|
|
17
|
+
*/
|
|
18
|
+
constructor(config?: NvisyGuestOptions);
|
|
19
|
+
/** The base URL used for API requests. */
|
|
20
|
+
get baseUrl(): string;
|
|
21
|
+
/** The underlying openapi-fetch client for direct API access. */
|
|
22
|
+
get api(): ApiClient;
|
|
23
|
+
/** Pre-auth sign-in: login, signup, and OIDC start. */
|
|
24
|
+
get auth(): GuestAuth;
|
|
25
|
+
/**
|
|
26
|
+
* The pre-auth capabilities read: `getAuthCapabilities()`. The label /
|
|
27
|
+
* recognizer / connector reads require an authenticated {@link Nvisy} client.
|
|
28
|
+
*/
|
|
29
|
+
get capabilities(): GuestCapabilities;
|
|
30
|
+
/** Health checks (liveness / readiness). */
|
|
31
|
+
get health(): Status;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export type { NvisyGuestOptions };
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/guest/client.ts"],"mappings":";;;;;;;;;qBA+Ba;;;;;;;;EAaA,YAAA,SAAQ;;MAWhB;;MAKA,OAAO;;MAKP,QAAQ;;;;;MAQR,gBAAgB;;MAKhB,UAAU"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { n as resolveDefaults, t as createApiClient } from "../http-BRaKBzAA.js";
|
|
2
|
+
import { a as Status, h as GuestAuth, m as GuestCapabilities } from "../services-BMmcawiT.js";
|
|
3
|
+
|
|
4
|
+
//#region src/guest/client.ts
|
|
5
|
+
/**
|
|
6
|
+
* Pre-auth Nvisy client. Wraps a token-less {@link ApiClient} and exposes the
|
|
7
|
+
* public surface: {@link GuestAuth}, {@link GuestCapabilities}, and
|
|
8
|
+
* {@link Status}. Configured with the shared {@link NvisyGuestOptions} (no auth); a
|
|
9
|
+
* guest client never sends a token. Pass `credentials: "include"` to send the
|
|
10
|
+
* session cookies set by login / signup on a cross-origin app.
|
|
11
|
+
*/
|
|
12
|
+
var NvisyGuest = class {
|
|
13
|
+
/** The resolved base URL. @internal */
|
|
14
|
+
#baseUrl;
|
|
15
|
+
/** The underlying openapi-fetch client instance. @internal */
|
|
16
|
+
#api;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new pre-auth Nvisy client (no API token).
|
|
19
|
+
*
|
|
20
|
+
* @param config - Optional configuration (baseUrl, credentials, headers,
|
|
21
|
+
* userAgent, fetch)
|
|
22
|
+
*/
|
|
23
|
+
constructor(config = {}) {
|
|
24
|
+
const resolved = resolveDefaults(config);
|
|
25
|
+
this.#baseUrl = resolved.baseUrl;
|
|
26
|
+
this.#api = createApiClient({
|
|
27
|
+
credentials: config.credentials,
|
|
28
|
+
fetch: config.fetch,
|
|
29
|
+
...resolved
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** The base URL used for API requests. */
|
|
33
|
+
get baseUrl() {
|
|
34
|
+
return this.#baseUrl;
|
|
35
|
+
}
|
|
36
|
+
/** The underlying openapi-fetch client for direct API access. */
|
|
37
|
+
get api() {
|
|
38
|
+
return this.#api;
|
|
39
|
+
}
|
|
40
|
+
/** Pre-auth sign-in: login, signup, and OIDC start. */
|
|
41
|
+
get auth() {
|
|
42
|
+
return new GuestAuth(this.#api);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The pre-auth capabilities read: `getAuthCapabilities()`. The label /
|
|
46
|
+
* recognizer / connector reads require an authenticated {@link Nvisy} client.
|
|
47
|
+
*/
|
|
48
|
+
get capabilities() {
|
|
49
|
+
return new GuestCapabilities(this.#api);
|
|
50
|
+
}
|
|
51
|
+
/** Health checks (liveness / readiness). */
|
|
52
|
+
get health() {
|
|
53
|
+
return new Status(this.#api);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { NvisyGuest };
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/guest/client.ts"],"sourcesContent":["/**\n * @fileoverview The pre-auth (\"guest\") Nvisy client.\n *\n * {@link NvisyGuest} exposes only the endpoints that work without an API token:\n * sign-in (login / signup / OIDC start), the deployment's auth capabilities, and\n * health checks. Use it to power a login screen before anyone has authenticated;\n * for the authenticated API, use {@link Nvisy} from `@nvisy/sdk`.\n *\n * @module guest\n *\n * @example\n * ```typescript\n * import { NvisyGuest } from \"@nvisy/sdk/guest\";\n *\n * const guest = new NvisyGuest({ baseUrl: \"https://api.nvisy.com\" });\n * const auth = await guest.capabilities.getAuthCapabilities();\n * await guest.auth.loginAccount({ identifier: \"user@example.com\", password: \"...\" });\n * ```\n */\n\nimport type { NvisyGuestOptions } from \"@/config.js\";\nimport { type ApiClient, createApiClient, resolveDefaults } from \"@/http.js\";\nimport { GuestAuth, GuestCapabilities, Status } from \"@/services/index.js\";\n\n/**\n * Pre-auth Nvisy client. Wraps a token-less {@link ApiClient} and exposes the\n * public surface: {@link GuestAuth}, {@link GuestCapabilities}, and\n * {@link Status}. Configured with the shared {@link NvisyGuestOptions} (no auth); a\n * guest client never sends a token. Pass `credentials: \"include\"` to send the\n * session cookies set by login / signup on a cross-origin app.\n */\nexport class NvisyGuest {\n\t/** The resolved base URL. @internal */\n\treadonly #baseUrl: string;\n\n\t/** The underlying openapi-fetch client instance. @internal */\n\treadonly #api: ApiClient;\n\n\t/**\n\t * Creates a new pre-auth Nvisy client (no API token).\n\t *\n\t * @param config - Optional configuration (baseUrl, credentials, headers,\n\t * userAgent, fetch)\n\t */\n\tconstructor(config: NvisyGuestOptions = {}) {\n\t\tconst resolved = resolveDefaults(config);\n\t\tthis.#baseUrl = resolved.baseUrl;\n\t\tthis.#api = createApiClient({\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/** The base URL used for API requests. */\n\tget baseUrl(): string {\n\t\treturn this.#baseUrl;\n\t}\n\n\t/** The underlying openapi-fetch client for direct API access. */\n\tget api(): ApiClient {\n\t\treturn this.#api;\n\t}\n\n\t/** Pre-auth sign-in: login, signup, and OIDC start. */\n\tget auth(): GuestAuth {\n\t\treturn new GuestAuth(this.#api);\n\t}\n\n\t/**\n\t * The pre-auth capabilities read: `getAuthCapabilities()`. The label /\n\t * recognizer / connector reads require an authenticated {@link Nvisy} client.\n\t */\n\tget capabilities(): GuestCapabilities {\n\t\treturn new GuestCapabilities(this.#api);\n\t}\n\n\t/** Health checks (liveness / readiness). */\n\tget health(): Status {\n\t\treturn new Status(this.#api);\n\t}\n}\n"],"mappings":";;;;;;;;;;;AA+BA,IAAa,aAAb,MAAwB;;CAEvB,AAAS;;CAGT,AAAS;;;;;;;CAQT,YAAY,SAA4B,CAAC,GAAG;EAC3C,MAAM,WAAW,gBAAgB,MAAM;EACvC,KAAK,WAAW,SAAS;EACzB,KAAK,OAAO,gBAAgB;GAC3B,aAAa,OAAO;GACpB,OAAO,OAAO;GACd,GAAG;EACJ,CAAC;CACF;;CAGA,IAAI,UAAkB;EACrB,OAAO,KAAK;CACb;;CAGA,IAAI,MAAiB;EACpB,OAAO,KAAK;CACb;;CAGA,IAAI,OAAkB;EACrB,OAAO,IAAI,UAAU,KAAK,IAAI;CAC/B;;;;;CAMA,IAAI,eAAkC;EACrC,OAAO,IAAI,kBAAkB,KAAK,IAAI;CACvC;;CAGA,IAAI,SAAiB;EACpB,OAAO,IAAI,OAAO,KAAK,IAAI;CAC5B;AACD"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { n as NvisyError, t as NvisyApiError } from "./errors-ChRSBkhj.js";
|
|
2
|
+
import createClient from "openapi-fetch";
|
|
3
|
+
|
|
4
|
+
//#region src/config.ts
|
|
5
|
+
/**
|
|
6
|
+
* Current SDK version.
|
|
7
|
+
*
|
|
8
|
+
* Injected from `package.json` at build time, so it always matches the
|
|
9
|
+
* published version. Used in the default user agent string.
|
|
10
|
+
*/
|
|
11
|
+
const VERSION = "0.55.0";
|
|
12
|
+
/**
|
|
13
|
+
* Default configuration values used when options are not explicitly provided.
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULTS = {
|
|
16
|
+
/**
|
|
17
|
+
* Default base URL for the Nvisy API.
|
|
18
|
+
*/
|
|
19
|
+
BASE_URL: "https://api.nvisy.com",
|
|
20
|
+
/**
|
|
21
|
+
* Default user agent string.
|
|
22
|
+
*/
|
|
23
|
+
USER_AGENT: `@nvisy/sdk v.${VERSION}`
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/middleware/error.ts
|
|
28
|
+
/**
|
|
29
|
+
* Middleware that automatically throws NvisyApiError for error responses.
|
|
30
|
+
* This replaces the need for manual checks in services.
|
|
31
|
+
*/
|
|
32
|
+
const errorMiddleware = {
|
|
33
|
+
async onResponse({ response }) {
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
const error = await response.clone().json();
|
|
36
|
+
throw new NvisyApiError(error, response.status);
|
|
37
|
+
}
|
|
38
|
+
return response;
|
|
39
|
+
},
|
|
40
|
+
onError({ error }) {
|
|
41
|
+
if (error instanceof Error) throw new NvisyError(error.message);
|
|
42
|
+
throw new NvisyError("An unknown network error occurred");
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/middleware/logging.ts
|
|
48
|
+
/**
|
|
49
|
+
* Creates a logging middleware for debugging requests and responses.
|
|
50
|
+
*
|
|
51
|
+
* Logs request method, URL, response status, and timing to console.
|
|
52
|
+
*/
|
|
53
|
+
function createLoggingMiddleware() {
|
|
54
|
+
return {
|
|
55
|
+
async onRequest({ request }) {
|
|
56
|
+
request._startTime = performance.now();
|
|
57
|
+
return request;
|
|
58
|
+
},
|
|
59
|
+
async onResponse({ request, response }) {
|
|
60
|
+
const start = request._startTime ?? performance.now();
|
|
61
|
+
const duration = Math.round(performance.now() - start);
|
|
62
|
+
const url = new URL(request.url);
|
|
63
|
+
console.log(`[nvisy] ${request.method} ${url.pathname} ${response.status} (${duration}ms)`);
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
const cloned = response.clone();
|
|
66
|
+
try {
|
|
67
|
+
const body = await cloned.json();
|
|
68
|
+
console.error("[nvisy] Response:", JSON.stringify(body, null, 2));
|
|
69
|
+
} catch {
|
|
70
|
+
const text = await cloned.text();
|
|
71
|
+
if (text) console.error("[nvisy] Response:", text);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return response;
|
|
75
|
+
},
|
|
76
|
+
onError({ request, error }) {
|
|
77
|
+
const start = request._startTime ?? performance.now();
|
|
78
|
+
const duration = Math.round(performance.now() - start);
|
|
79
|
+
const url = new URL(request.url);
|
|
80
|
+
console.error(`[nvisy] ${request.method} ${url.pathname} ERROR (${duration}ms):`, error instanceof Error ? error.message : error);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/http.ts
|
|
87
|
+
/**
|
|
88
|
+
* @fileoverview Shared openapi-fetch client factory used by both the
|
|
89
|
+
* authenticated {@link Nvisy} client and the pre-auth {@link NvisyGuest} client.
|
|
90
|
+
*
|
|
91
|
+
* @module http
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
/**
|
|
95
|
+
* Build a configured openapi-fetch client. A bearer `Authorization` header is
|
|
96
|
+
* sent only when `apiToken` is provided, so the same factory serves the
|
|
97
|
+
* authenticated and guest clients.
|
|
98
|
+
*/
|
|
99
|
+
function createApiClient(options) {
|
|
100
|
+
const headers = {
|
|
101
|
+
"Content-Type": "application/json",
|
|
102
|
+
"User-Agent": options.userAgent,
|
|
103
|
+
...options.apiToken ? { Authorization: `Bearer ${options.apiToken}` } : {},
|
|
104
|
+
...options.headers
|
|
105
|
+
};
|
|
106
|
+
const api = createClient({
|
|
107
|
+
baseUrl: options.baseUrl,
|
|
108
|
+
headers,
|
|
109
|
+
fetch: options.fetch,
|
|
110
|
+
...options.credentials ? { credentials: options.credentials } : {}
|
|
111
|
+
});
|
|
112
|
+
if (options.withLogging) api.use(createLoggingMiddleware());
|
|
113
|
+
api.use(errorMiddleware);
|
|
114
|
+
return api;
|
|
115
|
+
}
|
|
116
|
+
/** Apply the shared defaults (base URL, user agent) to a config's optionals. */
|
|
117
|
+
function resolveDefaults(config) {
|
|
118
|
+
return {
|
|
119
|
+
baseUrl: config.baseUrl ?? DEFAULTS.BASE_URL,
|
|
120
|
+
headers: config.headers ?? {},
|
|
121
|
+
userAgent: config.userAgent ?? DEFAULTS.USER_AGENT,
|
|
122
|
+
withLogging: config.withLogging ?? false
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { VERSION as i, resolveDefaults as n, DEFAULTS as r, createApiClient as t };
|
|
128
|
+
//# sourceMappingURL=http-BRaKBzAA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-BRaKBzAA.js","names":[],"sources":["../src/config.ts","../src/middleware/error.ts","../src/middleware/logging.ts","../src/http.ts"],"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 * Compile-time version token, replaced with the `package.json` version by the\n * build (see `tsdown.config.ts`). Declared so it type-checks; the `typeof`\n * guard below keeps it safe when the define isn't applied (tests, direct `tsc`).\n */\ndeclare const __SDK_VERSION__: string | undefined;\n\n/**\n * Current SDK version.\n *\n * Injected from `package.json` at build time, so it always matches the\n * published version. Used in the default user agent string.\n */\nexport const VERSION =\n\ttypeof __SDK_VERSION__ === \"string\" ? __SDK_VERSION__ : \"0.0.0-dev\";\n\n/**\n * Options for the pre-auth {@link NvisyGuest} client — the transport settings\n * shared by every client, with no authentication. All fields are optional and\n * use sensible defaults.\n */\nexport interface NvisyGuestOptions {\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 * Merged over the default headers (Content-Type, User-Agent, and, for token\n\t * auth, Authorization). Custom headers take precedence on conflict.\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 * Credentials mode forwarded to `fetch`. Session auth sets this to\n\t * `\"include\"` automatically; set it here only to override the transport\n\t * behaviour (e.g. a same-origin app that wants a different mode).\n\t */\n\tcredentials?: RequestCredentials;\n\n\t/**\n\t * Enable logging for requests and responses.\n\t *\n\t * @default false\n\t */\n\twithLogging?: boolean;\n\n\t/**\n\t * Custom fetch implementation used for every request. Must match the WHATWG\n\t * `fetch` signature. Defaults to the global `fetch`.\n\t *\n\t * Lets a host swap in a non-browser transport — e.g. a desktop (Tauri) app\n\t * passing `@tauri-apps/plugin-http`'s `fetch`, which performs the request in\n\t * the native process and so is not subject to browser CORS.\n\t */\n\tfetch?: typeof globalThis.fetch;\n}\n\n/**\n * Configuration for the authenticated {@link Nvisy} client. Authenticate one of\n * two ways, chosen explicitly:\n *\n * - `apiToken` — send an API token as `Authorization: Bearer <token>`.\n * - `session: true` — use the browser cookie session established by the guest\n * client's `login` / `signup`; requests are sent credentialed\n * (`credentials: \"include\"`).\n *\n * The two are mutually exclusive.\n *\n * @example\n * ```typescript\n * // API token\n * new Nvisy({ apiToken: \"your-api-token\" });\n *\n * // Browser cookie session (after the guest client logged in)\n * new Nvisy({ session: true });\n * ```\n */\nexport type NvisyOptions = NvisyGuestOptions &\n\t({ apiToken: string; session?: never } | { session: true; apiToken?: never });\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","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","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 Shared openapi-fetch client factory used by both the\n * authenticated {@link Nvisy} client and the pre-auth {@link NvisyGuest} client.\n *\n * @module http\n * @internal\n */\n\nimport createClient, { type Client as OpenApiClient } from \"openapi-fetch\";\nimport { DEFAULTS } from \"@/config.js\";\nimport {\n\tcreateLoggingMiddleware,\n\terrorMiddleware,\n} from \"@/middleware/index.js\";\nimport type { paths } from \"@/schema/api.js\";\n\n/** Typed openapi-fetch client for the Nvisy API. */\nexport type ApiClient = OpenApiClient<paths>;\n\n/** Resolved options for building an {@link ApiClient}. */\nexport interface ApiClientOptions {\n\t/** Bearer token to send as `Authorization`; omit for an unauthenticated client. */\n\tapiToken?: string;\n\t/** Base URL for the API. */\n\tbaseUrl: string;\n\t/** Custom headers merged over the defaults. */\n\theaders: Record<string, string>;\n\t/** User-agent string. */\n\tuserAgent: string;\n\t/** Credentials mode forwarded to `fetch` (e.g. `\"include\"` for cookies). */\n\tcredentials?: RequestCredentials;\n\t/** Whether to log requests/responses. */\n\twithLogging: boolean;\n\t/** Custom fetch implementation; `undefined` uses the global fetch. */\n\tfetch?: typeof globalThis.fetch;\n}\n\n/**\n * Build a configured openapi-fetch client. A bearer `Authorization` header is\n * sent only when `apiToken` is provided, so the same factory serves the\n * authenticated and guest clients.\n */\nexport function createApiClient(options: ApiClientOptions): ApiClient {\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\t\"User-Agent\": options.userAgent,\n\t\t// Send a bearer token only when configured; a guest client authenticates\n\t\t// with cookies (or not at all) instead.\n\t\t...(options.apiToken\n\t\t\t? { Authorization: `Bearer ${options.apiToken}` }\n\t\t\t: {}),\n\t\t...options.headers,\n\t};\n\n\tconst api = createClient<paths>({\n\t\tbaseUrl: options.baseUrl,\n\t\theaders,\n\t\t// `undefined` falls back to the global fetch inside openapi-fetch.\n\t\tfetch: options.fetch,\n\t\t// Omitted `credentials` uses the platform default.\n\t\t...(options.credentials ? { credentials: options.credentials } : {}),\n\t});\n\n\tif (options.withLogging) {\n\t\tapi.use(createLoggingMiddleware());\n\t}\n\n\tapi.use(errorMiddleware);\n\treturn api;\n}\n\n/** Apply the shared defaults (base URL, user agent) to a config's optionals. */\nexport function resolveDefaults<\n\tT extends {\n\t\tbaseUrl?: string;\n\t\theaders?: Record<string, string>;\n\t\tuserAgent?: string;\n\t\twithLogging?: boolean;\n\t},\n>(config: T) {\n\treturn {\n\t\tbaseUrl: config.baseUrl ?? DEFAULTS.BASE_URL,\n\t\theaders: config.headers ?? {},\n\t\tuserAgent: config.userAgent ?? DEFAULTS.USER_AGENT,\n\t\twithLogging: config.withLogging ?? false,\n\t};\n}\n"],"mappings":";;;;;;;;;;AAsBA,MAAa;;;;AAkFb,MAAa,WAAW;;;;CAIvB,UAAU;;;;CAKV,YAAY,gBAAgB;AAC7B;;;;;;;;AC1GA,MAAa,kBAA8B;CAC1C,MAAM,WAAW,EAAE,YAAY;EAC9B,IAAI,CAAC,SAAS,IAAI;GACjB,MAAM,QAAS,MAAM,SAAS,MAAM,CAAC,CAAC,KAAK;GAC3C,MAAM,IAAI,cAAc,OAAO,SAAS,MAAM;EAC/C;EACA,OAAO;CACR;CAEA,QAAQ,EAAE,SAAS;EAElB,IAAI,iBAAiB,OACpB,MAAM,IAAI,WAAW,MAAM,OAAO;EAEnC,MAAM,IAAI,WAAW,mCAAmC;CACzD;AACD;;;;;;;;;ACjBA,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,MAAM,QACJ,QAA8C,cAC/C,YAAY,IAAI;GACjB,MAAM,WAAW,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK;GACrD,MAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;GAE/B,QAAQ,IACP,WAAW,QAAQ,OAAO,GAAG,IAAI,SAAS,GAAG,SAAS,OAAO,IAAI,SAAS,IAC3E;GAEA,IAAI,CAAC,SAAS,IAAI;IACjB,MAAM,SAAS,SAAS,MAAM;IAC9B,IAAI;KACH,MAAM,OAAO,MAAM,OAAO,KAAK;KAC/B,QAAQ,MAAM,qBAAqB,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;IACjE,QAAQ;KACP,MAAM,OAAO,MAAM,OAAO,KAAK;KAC/B,IAAI,MAAM,QAAQ,MAAM,qBAAqB,IAAI;IAClD;GACD;GAEA,OAAO;EACR;EAEA,QAAQ,EAAE,SAAS,SAAS;GAC3B,MAAM,QACJ,QAA8C,cAC/C,YAAY,IAAI;GACjB,MAAM,WAAW,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK;GACrD,MAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;GAE/B,QAAQ,MACP,WAAW,QAAQ,OAAO,GAAG,IAAI,SAAS,UAAU,SAAS,OAC7D,iBAAiB,QAAQ,MAAM,UAAU,KAC1C;EACD;CACD;AACD;;;;;;;;;;;;;;;;ACXA,SAAgB,gBAAgB,SAAsC;CACrE,MAAM,UAAkC;EACvC,gBAAgB;EAChB,cAAc,QAAQ;EAGtB,GAAI,QAAQ,WACT,EAAE,eAAe,UAAU,QAAQ,WAAW,IAC9C,CAAC;EACJ,GAAG,QAAQ;CACZ;CAEA,MAAM,MAAM,aAAoB;EAC/B,SAAS,QAAQ;EACjB;EAEA,OAAO,QAAQ;EAEf,GAAI,QAAQ,cAAc,EAAE,aAAa,QAAQ,YAAY,IAAI,CAAC;CACnE,CAAC;CAED,IAAI,QAAQ,aACX,IAAI,IAAI,wBAAwB,CAAC;CAGlC,IAAI,IAAI,eAAe;CACvB,OAAO;AACR;;AAGA,SAAgB,gBAOd,QAAW;CACZ,OAAO;EACN,SAAS,OAAO,WAAW,SAAS;EACpC,SAAS,OAAO,WAAW,CAAC;EAC5B,WAAW,OAAO,aAAa,SAAS;EACxC,aAAa,OAAO,eAAe;CACpC;AACD"}
|