@semiont/core 0.5.3 → 0.5.4

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.
Files changed (89) hide show
  1. package/dist/annotation-assembly.d.ts +54 -0
  2. package/dist/annotation-assembly.d.ts.map +1 -0
  3. package/dist/annotation-types.d.ts +30 -0
  4. package/dist/annotation-types.d.ts.map +1 -0
  5. package/dist/annotation-utils.d.ts +43 -0
  6. package/dist/annotation-utils.d.ts.map +1 -0
  7. package/dist/auth-types.d.ts +8 -0
  8. package/dist/auth-types.d.ts.map +1 -0
  9. package/dist/branded-types.d.ts +70 -0
  10. package/dist/branded-types.d.ts.map +1 -0
  11. package/dist/bridged-channels.d.ts +18 -0
  12. package/dist/bridged-channels.d.ts.map +1 -0
  13. package/dist/bus-log.d.ts +25 -0
  14. package/dist/bus-log.d.ts.map +1 -0
  15. package/dist/bus-protocol.d.ts +510 -0
  16. package/dist/bus-protocol.d.ts.map +1 -0
  17. package/dist/{config.types-oPv3Ajk-.d.ts → config/config.types.d.ts} +25 -23
  18. package/dist/config/config.types.d.ts.map +1 -0
  19. package/dist/config/configuration-error.d.ts +17 -0
  20. package/dist/config/configuration-error.d.ts.map +1 -0
  21. package/dist/config/environment-validator.d.ts +28 -0
  22. package/dist/config/environment-validator.d.ts.map +1 -0
  23. package/dist/config/node-config-loader.d.ts +4 -74
  24. package/dist/config/node-config-loader.d.ts.map +1 -0
  25. package/dist/config/platform-types.d.ts +26 -0
  26. package/dist/config/platform-types.d.ts.map +1 -0
  27. package/dist/config/toml-loader.d.ts +59 -0
  28. package/dist/config/toml-loader.d.ts.map +1 -0
  29. package/dist/did-utils.d.ts +76 -0
  30. package/dist/did-utils.d.ts.map +1 -0
  31. package/dist/errors.d.ts +48 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/event-base.d.ts +70 -0
  34. package/dist/event-base.d.ts.map +1 -0
  35. package/dist/event-bus.d.ts +141 -0
  36. package/dist/event-bus.d.ts.map +1 -0
  37. package/dist/event-utils.d.ts +43 -0
  38. package/dist/event-utils.d.ts.map +1 -0
  39. package/dist/fuzzy-anchor.d.ts +81 -0
  40. package/dist/fuzzy-anchor.d.ts.map +1 -0
  41. package/dist/graph.d.ts +44 -0
  42. package/dist/graph.d.ts.map +1 -0
  43. package/dist/id-generation.d.ts +8 -0
  44. package/dist/id-generation.d.ts.map +1 -0
  45. package/dist/identifiers.d.ts +24 -0
  46. package/dist/identifiers.d.ts.map +1 -0
  47. package/dist/index.d.ts +59 -6022
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +41 -19
  50. package/dist/index.js.map +1 -1
  51. package/dist/locales.d.ts +31 -0
  52. package/dist/locales.d.ts.map +1 -0
  53. package/dist/logger.d.ts +56 -0
  54. package/dist/logger.d.ts.map +1 -0
  55. package/dist/mime-utils.d.ts +38 -0
  56. package/dist/mime-utils.d.ts.map +1 -0
  57. package/dist/operators/burst-buffer.d.ts +61 -0
  58. package/dist/operators/burst-buffer.d.ts.map +1 -0
  59. package/dist/payload-types.d.ts +16 -0
  60. package/dist/payload-types.d.ts.map +1 -0
  61. package/dist/persisted-events.d.ts +76 -0
  62. package/dist/persisted-events.d.ts.map +1 -0
  63. package/dist/project.d.ts +69 -0
  64. package/dist/project.d.ts.map +1 -0
  65. package/dist/resource-types.d.ts +15 -0
  66. package/dist/resource-types.d.ts.map +1 -0
  67. package/dist/resource-utils.d.ts +97 -0
  68. package/dist/resource-utils.d.ts.map +1 -0
  69. package/dist/serialize-per-key.d.ts +51 -0
  70. package/dist/serialize-per-key.d.ts.map +1 -0
  71. package/dist/svg-utils.d.ts +44 -0
  72. package/dist/svg-utils.d.ts.map +1 -0
  73. package/dist/tag-schemas.d.ts +27 -0
  74. package/dist/tag-schemas.d.ts.map +1 -0
  75. package/dist/text-context.d.ts +85 -0
  76. package/dist/text-context.d.ts.map +1 -0
  77. package/dist/text-encoding.d.ts +34 -0
  78. package/dist/text-encoding.d.ts.map +1 -0
  79. package/dist/transport.d.ts +274 -0
  80. package/dist/transport.d.ts.map +1 -0
  81. package/dist/type-guards.d.ts +44 -0
  82. package/dist/type-guards.d.ts.map +1 -0
  83. package/dist/types.d.ts +3517 -0
  84. package/dist/types.d.ts.map +1 -0
  85. package/dist/validation.d.ts +57 -0
  86. package/dist/validation.d.ts.map +1 -0
  87. package/dist/web-annotation-utils.d.ts +154 -0
  88. package/dist/web-annotation-utils.d.ts.map +1 -0
  89. package/package.json +3 -3
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Text context extraction utilities for W3C Web Annotation TextQuoteSelector
3
+ *
4
+ * Provides robust prefix/suffix context extraction with word boundary detection
5
+ * to ensure fuzzy anchoring works correctly when the same text appears multiple times.
6
+ *
7
+ * Also provides AI offset validation and correction for handling AI-generated annotations
8
+ * where the model may return slightly incorrect character offsets.
9
+ *
10
+ * @see https://www.w3.org/TR/annotation-model/#text-quote-selector
11
+ */
12
+ import { type MatchQuality } from './fuzzy-anchor';
13
+ /**
14
+ * Extract prefix and suffix context for TextQuoteSelector
15
+ *
16
+ * Extracts up to 64 characters before and after the selected text,
17
+ * extending to word boundaries to avoid cutting words in half.
18
+ * This ensures prefix/suffix are meaningful context for fuzzy anchoring.
19
+ *
20
+ * @param content - Full text content
21
+ * @param start - Start offset of selection
22
+ * @param end - End offset of selection
23
+ * @returns Object with prefix and suffix (undefined if at boundaries)
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const content = "The United States Congress...";
28
+ * const context = extractContext(content, 4, 17); // "United States"
29
+ * // Returns: { prefix: "The ", suffix: " Congress..." }
30
+ * // NOT: { prefix: "nited ", suffix: "gress..." }
31
+ * ```
32
+ */
33
+ export declare function extractContext(content: string, start: number, end: number): {
34
+ prefix?: string;
35
+ suffix?: string;
36
+ };
37
+ /**
38
+ * Result of validating and correcting AI-provided annotation offsets
39
+ */
40
+ export interface ValidatedAnnotation {
41
+ start: number;
42
+ end: number;
43
+ exact: string;
44
+ prefix?: string;
45
+ suffix?: string;
46
+ corrected: boolean;
47
+ fuzzyMatched?: boolean;
48
+ matchQuality?: MatchQuality;
49
+ }
50
+ /**
51
+ * Validate and correct AI-provided annotation offsets with fuzzy matching tolerance
52
+ *
53
+ * AI models sometimes return offsets that don't match the actual text position,
54
+ * or provide text with minor variations (case differences, whitespace, typos).
55
+ *
56
+ * This function uses a multi-strategy approach:
57
+ * 1. Check if AI's offsets are exactly correct
58
+ * 2. Try exact case-sensitive search
59
+ * 3. Try case-insensitive search
60
+ * 4. Try fuzzy matching with Levenshtein distance (5% tolerance)
61
+ *
62
+ * This ensures we're maximally tolerant of AI errors while still maintaining
63
+ * annotation quality and logging what corrections were made.
64
+ *
65
+ * @param content - Full text content
66
+ * @param aiStart - Start offset from AI
67
+ * @param aiEnd - End offset from AI
68
+ * @param exact - The exact text that should be at this position (from AI)
69
+ * @returns Validated annotation with corrected offsets and context
70
+ * @throws Error if no acceptable match can be found
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * // AI said start=1143, but actual text is at 1161
75
+ * const result = validateAndCorrectOffsets(
76
+ * content,
77
+ * 1143,
78
+ * 1289,
79
+ * "the question \"whether..."
80
+ * );
81
+ * // Returns: { start: 1161, end: 1303, exact: "...", corrected: true, matchQuality: 'exact', ... }
82
+ * ```
83
+ */
84
+ export declare function validateAndCorrectOffsets(content: string, aiStart: number, aiEnd: number, exact: string): ValidatedAnnotation;
85
+ //# sourceMappingURL=text-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-context.d.ts","sourceRoot":"","sources":["../src/text-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAwC,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CA+CtC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,mBAAmB,CA6CrB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Text encoding utilities for consistent charset handling
3
+ *
4
+ * Ensures frontend decoding matches backend decoding by respecting
5
+ * charset parameters in mediaType (e.g., "text/plain; charset=iso-8859-1")
6
+ */
7
+ /**
8
+ * Extract charset from mediaType parameter
9
+ *
10
+ * @param mediaType - Media type with optional charset (e.g., "text/plain; charset=utf-8")
11
+ * @returns Charset name in lowercase (defaults to "utf-8")
12
+ *
13
+ * @example
14
+ * extractCharset("text/plain; charset=iso-8859-1") // "iso-8859-1"
15
+ * extractCharset("text/plain") // "utf-8"
16
+ */
17
+ export declare function extractCharset(mediaType: string): string;
18
+ /**
19
+ * Decode ArrayBuffer to string using charset from mediaType
20
+ *
21
+ * Uses TextDecoder with the charset extracted from mediaType parameter.
22
+ * This ensures the same character space is used for both annotation creation
23
+ * (backend) and rendering (frontend).
24
+ *
25
+ * @param buffer - Binary data to decode
26
+ * @param mediaType - Media type with optional charset parameter
27
+ * @returns Decoded string in the original character space
28
+ *
29
+ * @example
30
+ * const buffer = new Uint8Array([...]);
31
+ * const text = decodeWithCharset(buffer, "text/plain; charset=iso-8859-1");
32
+ */
33
+ export declare function decodeWithCharset(buffer: ArrayBuffer, mediaType: string): string;
34
+ //# sourceMappingURL=text-encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-encoding.d.ts","sourceRoot":"","sources":["../src/text-encoding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAUhF"}
@@ -0,0 +1,274 @@
1
+ /**
2
+ * Transport interfaces — the shared contract for any wire-or-local
3
+ * communication path consumed by `SemiontClient`. Concrete implementations
4
+ * live alongside the runtime they wrap (`HttpTransport` in
5
+ * `@semiont/api-client`, in-process variants in `@semiont/make-meaning`,
6
+ * etc.).
7
+ *
8
+ * Three interfaces:
9
+ *
10
+ * ITransport — bus primitives + lifecycle. Universal: every
11
+ * concrete transport implements this.
12
+ * IBackendOperations — auth, admin, exchange, system endpoints.
13
+ * HTTP-shaped today; an in-process transport may
14
+ * implement none, some, or a different set.
15
+ * Optional on `SemiontClient` — passed only when
16
+ * the host has a backend that supports them.
17
+ * IContentTransport — binary I/O (putBinary / getBinary). Narrow by
18
+ * design because binary has different backpressure
19
+ * and streaming characteristics.
20
+ *
21
+ * The behavioral guarantees every implementation must honor are documented
22
+ * in `docs/protocol/TRANSPORT-CONTRACT.md`.
23
+ */
24
+ import type { Observable } from 'rxjs';
25
+ import type { components, paths } from './types';
26
+ import type { AccessToken, BaseUrl, ContentFormat, Email, GoogleCredential, RefreshToken, UserDID } from './branded-types';
27
+ import type { AnnotationId, ResourceId } from './identifiers';
28
+ import type { EventMap } from './bus-protocol';
29
+ import type { EventBus } from './event-bus';
30
+ import type { SemiontError } from './errors';
31
+ type Agent = components['schemas']['Agent'];
32
+ /**
33
+ * Six-state lifecycle for a transport's connection. Drives UI affordances
34
+ * (connecting spinners, reconnecting banners, etc.) and is observed via
35
+ * `ITransport.state$`.
36
+ *
37
+ * initial ─ pre-`start()`; never enters subscribers' streams
38
+ * except as the first replayed value
39
+ * connecting ─ in-flight initial open
40
+ * open ─ healthy, delivering events
41
+ * reconnecting ─ open → dropped, retrying; may be transient
42
+ * degraded ─ has been reconnecting for > DEGRADED_THRESHOLD_MS;
43
+ * UI banner threshold; distinguishes brief mount-
44
+ * churn cycles from sustained disconnection
45
+ * closed ─ stop()/dispose() called; terminal
46
+ */
47
+ export type ConnectionState = 'initial' | 'connecting' | 'open' | 'reconnecting' | 'degraded' | 'closed';
48
+ type AuthResponse = components['schemas']['AuthResponse'];
49
+ type TokenRefreshResponse = components['schemas']['TokenRefreshResponse'];
50
+ type AdminUserStatsResponse = components['schemas']['AdminUserStatsResponse'];
51
+ type OAuthConfigResponse = components['schemas']['OAuthConfigResponse'];
52
+ type ResponseContent<T> = T extends {
53
+ responses: {
54
+ 200: {
55
+ content: {
56
+ 'application/json': infer R;
57
+ };
58
+ };
59
+ };
60
+ } ? R : T extends {
61
+ responses: {
62
+ 201: {
63
+ content: {
64
+ 'application/json': infer R;
65
+ };
66
+ };
67
+ };
68
+ } ? R : T extends {
69
+ responses: {
70
+ 202: {
71
+ content: {
72
+ 'application/json': infer R;
73
+ };
74
+ };
75
+ };
76
+ } ? R : never;
77
+ type RequestContent<T> = T extends {
78
+ requestBody?: {
79
+ content: {
80
+ 'application/json': infer R;
81
+ };
82
+ };
83
+ } ? R : never;
84
+ export type HealthCheckResponse = ResponseContent<paths['/api/health']['get']>;
85
+ export type StatusResponse = ResponseContent<paths['/api/status']['get']>;
86
+ export type UserResponse = ResponseContent<paths['/api/users/me']['get']>;
87
+ export type UpdateUserRequest = RequestContent<paths['/api/admin/users/{id}']['patch']>;
88
+ export type UpdateUserResponse = ResponseContent<paths['/api/admin/users/{id}']['patch']>;
89
+ export type ListUsersResponse = ResponseContent<paths['/api/admin/users']['get']>;
90
+ export type ProgressEvent = {
91
+ phase: string;
92
+ message?: string;
93
+ result?: Record<string, unknown>;
94
+ };
95
+ export type ProgressCallback = (event: ProgressEvent) => void;
96
+ /**
97
+ * Stream-shaped return type for backend download operations
98
+ * (`backupKnowledgeBase`, `exportKnowledgeBase`). Transport-neutral —
99
+ * any implementation can produce a `ReadableStream<Uint8Array>` without
100
+ * fabricating a fetch `Response`. HTTP wraps `response.body` and
101
+ * `response.headers`; in-process implementations return their own stream.
102
+ *
103
+ * The same shape `IContentTransport.getBinaryStream` already uses for
104
+ * binary downloads.
105
+ */
106
+ export interface BackendDownload {
107
+ stream: ReadableStream<Uint8Array>;
108
+ contentType: string;
109
+ filename?: string;
110
+ }
111
+ export interface ITransport {
112
+ /**
113
+ * Base URL the transport speaks to. For HTTP this is `https://host[:port]`;
114
+ * for in-process transports, an opaque identifier (e.g. `local://kb-id`).
115
+ */
116
+ readonly baseUrl: BaseUrl;
117
+ /**
118
+ * Publish a payload on the named channel.
119
+ *
120
+ * `resourceScope`, when set, marks the emit as a resource-scoped
121
+ * broadcast — only delivered to subscribers attached to that
122
+ * resource's scope.
123
+ */
124
+ emit<K extends keyof EventMap>(channel: K, payload: EventMap[K], resourceScope?: ResourceId): Promise<void>;
125
+ on<K extends keyof EventMap>(channel: K, handler: (payload: EventMap[K]) => void): () => void;
126
+ stream<K extends keyof EventMap>(channel: K): Observable<EventMap[K]>;
127
+ /**
128
+ * Subscribe to a resource-scoped channel set. HTTP attaches a scope to
129
+ * its SSE connection; in-process transports may be a no-op because
130
+ * local events are delivered without scoping.
131
+ *
132
+ * Returns a disposer that detaches the scope when the last subscriber
133
+ * unsubscribes (ref-counted).
134
+ */
135
+ subscribeToResource(resourceId: ResourceId): () => void;
136
+ /**
137
+ * Hand the given bus to the transport so the transport can publish
138
+ * the events it receives into it. The reference flows
139
+ * client → transport (the client owns the bus); transports never
140
+ * construct or replace it. Concrete transports decide what "receives"
141
+ * means: HTTP bridges every channel it observes on its SSE wire;
142
+ * an in-process transport bridges from the local actor bus.
143
+ */
144
+ bridgeInto(bus: EventBus): void;
145
+ /**
146
+ * Transport-level connection state. For HTTP, reflects the SSE
147
+ * connection's health; for in-process transports, typically `'open'`
148
+ * from construction onward (no connection to lose).
149
+ */
150
+ readonly state$: Observable<ConnectionState>;
151
+ /**
152
+ * Stream of transport-level errors surfaced from typed-wire methods or
153
+ * other transport-mediated round-trips, just before they're thrown to
154
+ * the caller. Each emission is a `SemiontError` (or subclass — HTTP
155
+ * emits `APIError`, in-process transports emit whatever subclass is
156
+ * appropriate). Consumers can subscribe for global error handling
157
+ * (e.g. surfacing 401/403 as modals, logging) without wrapping every
158
+ * call site in try/catch. Distinct from bus-level errors, which are
159
+ * surfaced via the channel-correlation pattern in `busRequest`.
160
+ */
161
+ readonly errors$: Observable<SemiontError>;
162
+ dispose(): void;
163
+ }
164
+ /**
165
+ * Auth, admin, exchange, and system endpoints. HTTP-shaped today —
166
+ * `HttpTransport` implements both this and `ITransport`; the
167
+ * `SemiontClient` constructor takes a `IBackendOperations` argument
168
+ * separately from the bus transport so non-HTTP transports
169
+ * (`LocalTransport`) can implement just the bus surface and the
170
+ * SemiontClient cleanly omits `client.auth` / `client.admin`.
171
+ *
172
+ * Implementations should map their native error codes to
173
+ * `TransportErrorCode` (see `errors.ts`) so the routing layer
174
+ * (`SemiontBrowser`) stays transport-neutral.
175
+ */
176
+ export interface IBackendOperations {
177
+ authenticatePassword(email: Email, password: string): Promise<AuthResponse>;
178
+ authenticateGoogle(credential: GoogleCredential): Promise<AuthResponse>;
179
+ refreshAccessToken(token: RefreshToken): Promise<TokenRefreshResponse>;
180
+ logout(): Promise<void>;
181
+ acceptTerms(): Promise<void>;
182
+ getCurrentUser(): Promise<UserResponse>;
183
+ generateMcpToken(): Promise<{
184
+ token: string;
185
+ }>;
186
+ getMediaToken(resourceId: ResourceId): Promise<{
187
+ token: string;
188
+ }>;
189
+ listUsers(): Promise<ListUsersResponse>;
190
+ getUserStats(): Promise<AdminUserStatsResponse>;
191
+ updateUser(id: UserDID, data: UpdateUserRequest): Promise<UpdateUserResponse>;
192
+ getOAuthConfig(): Promise<OAuthConfigResponse>;
193
+ backupKnowledgeBase(): Promise<BackendDownload>;
194
+ /**
195
+ * Stream of `ProgressEvent`s for a restore/import operation. The
196
+ * Observable emits each progress event in order and completes when
197
+ * the operation is done; the final event carries `phase: 'complete'`
198
+ * (or `'error'` / `'failed'` followed by an Observable error).
199
+ *
200
+ * The SDK wraps the contract's `Observable<ProgressEvent>` as a
201
+ * `StreamObservable<ProgressEvent>` so consumers can `await` for the
202
+ * final event or `.subscribe(...)` to render every step.
203
+ */
204
+ restoreKnowledgeBase(file: File): Observable<ProgressEvent>;
205
+ exportKnowledgeBase(params?: {
206
+ includeArchived?: boolean;
207
+ }): Promise<BackendDownload>;
208
+ importKnowledgeBase(file: File): Observable<ProgressEvent>;
209
+ healthCheck(): Promise<HealthCheckResponse>;
210
+ getStatus(): Promise<StatusResponse>;
211
+ }
212
+ export interface PutBinaryRequest {
213
+ name: string;
214
+ file: File | Buffer;
215
+ format: ContentFormat | string;
216
+ storageUri: string;
217
+ entityTypes?: string[];
218
+ language?: string;
219
+ sourceAnnotationId?: AnnotationId | string;
220
+ sourceResourceId?: ResourceId | string;
221
+ generationPrompt?: string;
222
+ generator?: Agent | Agent[];
223
+ isDraft?: boolean;
224
+ }
225
+ /**
226
+ * Optional byte-progress hook for `putBinary`. Receives raw byte counts;
227
+ * derived shapes (percentage, ETA) are the caller's responsibility.
228
+ *
229
+ * `totalBytes` may be 0 when the underlying transport can't determine it
230
+ * (chunked encoding, indeterminate streams). Consumers should render an
231
+ * indeterminate state in that case.
232
+ */
233
+ export type PutBinaryProgress = (event: {
234
+ bytesUploaded: number;
235
+ totalBytes: number;
236
+ }) => void;
237
+ export interface PutBinaryOptions {
238
+ auth?: AccessToken;
239
+ /**
240
+ * Called as bytes flow over the wire. Honored by transports that can
241
+ * observe upload progress (HTTP via XHR). Transports that can't
242
+ * (in-process LocalContentTransport, current `ky`-based fetch path
243
+ * with no `onProgress`) simply ignore it.
244
+ */
245
+ onProgress?: PutBinaryProgress;
246
+ /**
247
+ * Signal that aborts the in-flight request. The XHR-based HTTP path
248
+ * calls `xhr.abort()` when the signal fires; in-process and
249
+ * non-XHR HTTP paths complete in the background after abort.
250
+ */
251
+ signal?: AbortSignal;
252
+ }
253
+ export interface IContentTransport {
254
+ putBinary(request: PutBinaryRequest, options?: PutBinaryOptions): Promise<{
255
+ resourceId: ResourceId;
256
+ }>;
257
+ getBinary(resourceId: ResourceId, options?: {
258
+ accept?: ContentFormat | string;
259
+ auth?: AccessToken;
260
+ }): Promise<{
261
+ data: ArrayBuffer;
262
+ contentType: string;
263
+ }>;
264
+ getBinaryStream(resourceId: ResourceId, options?: {
265
+ accept?: ContentFormat | string;
266
+ auth?: AccessToken;
267
+ }): Promise<{
268
+ stream: ReadableStream<Uint8Array>;
269
+ contentType: string;
270
+ }>;
271
+ dispose(): void;
272
+ }
273
+ export {};
274
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,OAAO,EACP,aAAa,EACb,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,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function isString(value: unknown): value is string;
8
+ /**
9
+ * Check if value is a number (not NaN)
10
+ */
11
+ export declare function isNumber(value: unknown): value is number;
12
+ /**
13
+ * Check if value is an object (not null, not array)
14
+ */
15
+ export declare function isObject(value: unknown): value is Record<string, unknown>;
16
+ /**
17
+ * Check if value is an array
18
+ */
19
+ export declare function isArray(value: unknown): value is unknown[];
20
+ /**
21
+ * Check if value is a boolean
22
+ */
23
+ export declare function isBoolean(value: unknown): value is boolean;
24
+ /**
25
+ * Check if value is a function
26
+ */
27
+ export declare function isFunction(value: unknown): value is Function;
28
+ /**
29
+ * Check if value is null
30
+ */
31
+ export declare function isNull(value: unknown): value is null;
32
+ /**
33
+ * Check if value is undefined
34
+ */
35
+ export declare function isUndefined(value: unknown): value is undefined;
36
+ /**
37
+ * Check if value is null or undefined
38
+ */
39
+ export declare function isNullish(value: unknown): value is null | undefined;
40
+ /**
41
+ * Check if value is defined (not null or undefined)
42
+ */
43
+ export declare function isDefined<T>(value: T | null | undefined): value is T;
44
+ //# sourceMappingURL=type-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../src/type-guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,EAAE,CAE1D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,SAAS,CAEnE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,CAAC,CAEpE"}