@powerhousedao/reactor-attachments 6.1.0-dev.19 → 6.1.0-dev.20

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/dist/client.d.ts CHANGED
@@ -1,618 +1,6 @@
1
- import { AttachmentHash, AttachmentRef, JwtHandler } from "@powerhousedao/reactor";
1
+ import { A as ReserveAttachmentOptions, B as SizeMismatch, C as AttachmentMetadata, D as AttachmentUploadResult, E as AttachmentTransportConfig, F as AttachmentNotFound, I as AttachmentPending, L as HashMismatch, M as TransportResponse, N as UploadFirstReserveAttachmentOptions, O as HashFirstReserveAttachmentOptions, P as AttachmentAlreadyExists, R as InvalidAttachmentRef, S as AttachmentHeader, T as AttachmentStatus, V as UploadTooLarge, _ as IAttachmentTransport, a as RemoteAttachmentUpload, b as IAttachmentUploadFactory, c as SwitchboardAttachmentTransport, d as createRef, f as parseRef, g as IAttachmentStore, h as IAttachmentService, i as RemoteAttachmentUploadFactory, j as TransportFetchResult, k as Reservation, l as SwitchboardTransportConfig, m as IAttachmentReader, n as createRemoteAttachmentService, o as RemoteReservationStore, p as AttachmentService, r as RemoteAttachmentStore, s as SwitchboardClientConfig, t as NullAttachmentTransport, u as ParsedRef, v as IAttachmentTransportFactory, w as AttachmentResponse, x as IReservationStore, y as IAttachmentUpload, z as ReservationNotFound } from "./null-attachment-transport-BBhQIk5A.js";
2
+ import { AttachmentHash, AttachmentRef } from "@powerhousedao/reactor";
2
3
 
3
- //#region src/types.d.ts
4
- /**
5
- * Status of attachment data in the local store.
6
- * 'pending' is a virtual status synthesized at query time from live,
7
- * hash-bearing reservations -- it never appears in the attachment table.
8
- */
9
- type AttachmentStatus = "available" | "evicted" | "pending";
10
- /**
11
- * Metadata about an attachment. For committed attachments (available/evicted),
12
- * expiresAtUtc is null. For pending attachments synthesized from a live
13
- * reservation, expiresAtUtc carries the reservation expiry so callers can
14
- * emit Retry-After or bound polling loops.
15
- */
16
- type AttachmentHeader = {
17
- hash: AttachmentHash;
18
- mimeType: string;
19
- fileName: string;
20
- sizeBytes: number;
21
- extension: string | null;
22
- status: AttachmentStatus;
23
- source: "local" | "sync";
24
- createdAtUtc: string;
25
- lastAccessedAtUtc: string;
26
- expiresAtUtc: string | null;
27
- };
28
- /**
29
- * Metadata provided alongside attachment data during sync, and returned
30
- * via the switchboard's `Attachment-Metadata` header on GET/HEAD.
31
- * `createdAtUtc` is the original upload time, propagated from the source
32
- * so that the receiving store preserves it instead of synthesizing the
33
- * fetch time. `lastAccessedAtUtc` is the source reactor's most recent
34
- * access time; it is optional because not every producer (e.g. a fresh
35
- * `put` from a transport) tracks access yet. Receiving stores that
36
- * persist locally (LRU concerns) reset it on every read regardless.
37
- *
38
- * Reliability note: `lastAccessedAtUtc` arriving over the wire is
39
- * best-effort. When the producer omits it, the consumer (see
40
- * `RemoteAttachmentStore` / `SwitchboardAttachmentTransport`) coalesces
41
- * with `createdAtUtc`, so the field can silently equal `createdAtUtc`
42
- * even on a server that has never been read. Do NOT use the wire value
43
- * for LRU eviction or staleness decisions on remote data; always read
44
- * the field from the local store after persistence, where the receiving
45
- * store is the authority.
46
- */
47
- type AttachmentMetadata = {
48
- mimeType: string;
49
- fileName: string;
50
- sizeBytes: number;
51
- extension: string | null;
52
- createdAtUtc: string;
53
- lastAccessedAtUtc?: string;
54
- };
55
- /**
56
- * Upload-first reservation. clientHash and sizeBytes are absent;
57
- * the ref is only known after send() completes.
58
- */
59
- type UploadFirstReserveAttachmentOptions = {
60
- mimeType: string;
61
- fileName: string;
62
- extension?: string | null;
63
- clientHash?: undefined;
64
- sizeBytes?: undefined;
65
- };
66
- /**
67
- * Hash-first reservation. clientHash is present and sizeBytes is required.
68
- * The ref is known at reservation time; send() verifies the uploaded bytes
69
- * against the claimed hash and declared size. The explicit "?: undefined"
70
- * on UploadFirstReserveAttachmentOptions makes clientHash a narrowing discriminant:
71
- * checking options.clientHash !== undefined narrows sizeBytes to number.
72
- */
73
- type HashFirstReserveAttachmentOptions = {
74
- mimeType: string;
75
- fileName: string;
76
- extension?: string | null;
77
- /**
78
- * Content hash claimed by the client (lowercase SHA-256 hex).
79
- */
80
- clientHash: AttachmentHash;
81
- /**
82
- * Declared size in bytes. Required when clientHash is present.
83
- * Reported by stat() during the pending window and enforced on
84
- * ingest: an upload whose actual byte count differs is rejected.
85
- */
86
- sizeBytes: number;
87
- };
88
- /**
89
- * Options provided when reserving an attachment slot.
90
- *
91
- * Use HashFirstReserveAttachmentOptions when clientHash is known up front;
92
- * the service then operates in hash-first mode: reserve() rejects if the
93
- * content is already available, and send() verifies the uploaded bytes.
94
- *
95
- * Use UploadFirstReserveAttachmentOptions (or omit clientHash) for the
96
- * upload-first flow where the ref is only known after send() completes.
97
- */
98
- type ReserveAttachmentOptions = UploadFirstReserveAttachmentOptions | HashFirstReserveAttachmentOptions;
99
- /**
100
- * Result of uploading attachment data through a handle.
101
- */
102
- type AttachmentUploadResult = {
103
- hash: AttachmentHash;
104
- ref: AttachmentRef;
105
- header: AttachmentHeader;
106
- };
107
- /**
108
- * Response when retrieving attachment data from the local store.
109
- */
110
- type AttachmentResponse = {
111
- header: AttachmentHeader;
112
- body: ReadableStream<Uint8Array>;
113
- };
114
- /**
115
- * Response when fetching attachment data from a remote transport.
116
- * Lighter than AttachmentResponse -- a remote peer cannot meaningfully
117
- * populate status or source, which are local reactor concerns.
118
- * The store assigns those fields when it calls put() on receipt.
119
- */
120
- type TransportResponse = {
121
- hash: AttachmentHash;
122
- metadata: AttachmentMetadata;
123
- body: ReadableStream<Uint8Array>;
124
- };
125
- /**
126
- * Three-way result from IAttachmentTransport.fetch(). Replaces
127
- * TransportResponse | null to make the pending state explicit, so
128
- * peers receiving a synced operation whose attachment is in-flight can
129
- * distinguish "retry later" from "permanently unknown".
130
- */
131
- type TransportFetchResult = {
132
- kind: "data";
133
- response: TransportResponse;
134
- } | {
135
- kind: "pending";
136
- hash: AttachmentHash;
137
- expiresAtUtc: string;
138
- retryAfterMs: number;
139
- } | {
140
- kind: "not-found";
141
- };
142
- /**
143
- * Configuration for creating an attachment transport instance.
144
- */
145
- type AttachmentTransportConfig = {
146
- type: string;
147
- parameters: Record<string, unknown>;
148
- };
149
- /**
150
- * A reservation for an in-progress attachment upload.
151
- * Created by reserve(), deleted when upload.send() completes or
152
- * once expiresAtUtc has passed and a sweep runs.
153
- * clientHash and sizeBytes are set in hash-first mode and null in
154
- * upload-first mode.
155
- */
156
- type Reservation = {
157
- reservationId: string;
158
- mimeType: string;
159
- fileName: string;
160
- extension: string | null;
161
- createdAtUtc: string;
162
- expiresAtUtc: string;
163
- clientHash: string | null;
164
- sizeBytes: number | null;
165
- };
166
- //#endregion
167
- //#region src/interfaces.d.ts
168
- /**
169
- * Client-facing interface for uploading, querying, and retrieving attachments.
170
- * This is what applications (editors, Connect, CLI tools) interact with.
171
- */
172
- interface IAttachmentService {
173
- /**
174
- * Reserve a new attachment slot and return an upload handle.
175
- *
176
- * When options.clientHash is provided (hash-first mode):
177
- * - @throws AttachmentAlreadyExists if data for that hash is currently
178
- * available. The error carries the canonical ref; the caller uses it
179
- * directly and uploads nothing (dedup fast path).
180
- * - If the hash is evicted, the reservation is created: the client holds
181
- * the bytes and the upload restores them.
182
- * - If the hash is pending (another in-flight reservation), the
183
- * reservation is created: concurrent reservations are deliberately
184
- * permitted (see design doc -- no uniqueness race).
185
- * - The returned handle's ref field is set immediately to the computed ref.
186
- *
187
- * When options.clientHash is absent (upload-first mode):
188
- * - No pre-check against the store.
189
- * - The returned handle's ref field is null until send() completes.
190
- */
191
- reserve(options: ReserveAttachmentOptions): Promise<IAttachmentUpload>;
192
- /**
193
- * Get attachment metadata by ref.
194
- *
195
- * @throws AttachmentNotFound if the ref is unknown.
196
- * Returns an AttachmentHeader with status='pending' and expiresAtUtc set if
197
- * the hash has an active reservation but no committed bytes. Callers must
198
- * check header.status to distinguish pending from available.
199
- */
200
- stat(ref: AttachmentRef): Promise<AttachmentHeader>;
201
- /**
202
- * Retrieve attachment data.
203
- *
204
- * Always succeeds for any known, available ref. The underlying store
205
- * handles re-fetching evicted data from the transport transparently.
206
- *
207
- * @throws AttachmentPending if the hash is reserved but bytes not yet
208
- * available. There is no store-level wait; polling across the
209
- * pending window is the caller's loop, bounded by the error's
210
- * expiresAtUtc. A wait inside get() would hold request handlers
211
- * open across multi-second windows and hide retry policy where
212
- * callers cannot tune it.
213
- */
214
- get(ref: AttachmentRef, signal?: AbortSignal): Promise<AttachmentResponse>;
215
- }
216
- /**
217
- * Upload handle returned by reserve(). Encapsulates all transport-specific
218
- * concerns (URLs, credentials, streaming protocols) behind a single send() method.
219
- */
220
- interface IAttachmentUpload {
221
- /**
222
- * Unique identifier for this reservation.
223
- */
224
- reservationId: string;
225
- /**
226
- * The ref this upload will produce. Set immediately when the
227
- * reservation carries a client hash (hash-first mode); null in the
228
- * upload-first flow, where the ref is only known after send() completes.
229
- */
230
- ref: AttachmentRef | null;
231
- /**
232
- * Reservation TTL contract, from the server in remote mode.
233
- * ISO 8601 UTC string indicating when the reservation expires.
234
- * Clients use this to bound retry windows and populate the pending-upload queue.
235
- */
236
- readonly expiresAtUtc: string;
237
- /**
238
- * Stream attachment data through this handle.
239
- *
240
- * The handle manages the full upload lifecycle internally:
241
- * writing bytes to the backing store, computing or verifying
242
- * the content hash, creating the attachment record, and
243
- * cleaning up the reservation.
244
- *
245
- * Dedup: if an attachment with the same content hash already
246
- * exists, send() returns the existing ref. Content-addressed
247
- * storage means identical uploads converge on the same hash.
248
- *
249
- * When the reservation carries a client hash, the handle verifies
250
- * the received bytes against the claims:
251
- * - @throws SizeMismatch if the byte count differs from the declared
252
- * sizeBytes. The handle may reject mid-stream as soon as the count
253
- * exceeds the declaration, without consuming the rest.
254
- * - @throws HashMismatch if the server-computed hash differs from the
255
- * claimed hash. Nothing is committed; the reservation is retained
256
- * so the client can retry with the correct bytes.
257
- *
258
- * @returns The content hash, ref, and header for the uploaded attachment.
259
- */
260
- send(data: ReadableStream<Uint8Array>): Promise<AttachmentUploadResult>;
261
- }
262
- /**
263
- * Read-only subset of IAttachmentStore.
264
- *
265
- * Adapters that cannot safely support the local-only write/GC surface
266
- * (remote stores, forwarding caches) implement this narrow interface
267
- * instead of stub-rejecting unsupported methods. Consumers that only
268
- * need to query metadata or stream attachment bytes can take this type
269
- * to make their dependency requirements explicit.
270
- */
271
- interface IAttachmentReader {
272
- /**
273
- * Get attachment metadata without streaming body data.
274
- * Does NOT update lastAccessedAtUtc -- this is a metadata check,
275
- * not a data access.
276
- *
277
- * @throws AttachmentNotFound if the hash is unknown.
278
- * Returns an AttachmentHeader with status='pending' and expiresAtUtc set if
279
- * the hash has an active reservation but no committed bytes. Callers must
280
- * check header.status to distinguish pending from available.
281
- */
282
- stat(hash: AttachmentHash): Promise<AttachmentHeader>;
283
- /**
284
- * Retrieve attachment header and data stream by hash.
285
- * Updates lastAccessedAtUtc on access.
286
- *
287
- * If the data has been evicted, re-fetches it from the transport,
288
- * restores it locally via put(), and returns the data. This makes
289
- * eviction transparent to callers -- get() always succeeds for
290
- * any known, available hash.
291
- *
292
- * @throws AttachmentNotFound if the hash is unknown (no metadata
293
- * record exists and no pending reservation).
294
- * @throws AttachmentPending if the hash is reserved by an in-flight
295
- * upload; bytes are not yet available. There is no store-level
296
- * wait -- polling is the caller's responsibility.
297
- */
298
- get(hash: AttachmentHash, signal?: AbortSignal): Promise<AttachmentResponse>;
299
- }
300
- /**
301
- * Reactor-facing interface for managing local attachment data.
302
- * The IAttachmentTransport calls put when it receives data from a remote.
303
- * The store notifies its configured transport when new data arrives,
304
- * forming a bidirectional store-transport pair.
305
- */
306
- interface IAttachmentStore extends IAttachmentReader {
307
- /**
308
- * Check whether attachment data is available locally.
309
- * Returns true if the bytes can be served from this reactor's store
310
- * without a transport round-trip. Does not trigger a remote fetch.
311
- * Returns false for pending and evicted hashes.
312
- */
313
- has(hash: AttachmentHash): Promise<boolean>;
314
- /**
315
- * Store attachment data received from a remote (during sync or re-fetch).
316
- * Called by IAttachmentTransport implementations during sync, and
317
- * internally by get() when restoring evicted data.
318
- *
319
- * Behavior depends on existing state:
320
- * - No existing row: INSERT with source='sync', status='available'.
321
- * - Existing row with status='evicted': restore data, set status
322
- * to 'available'.
323
- * - Existing row with status='available': no-op (dedup).
324
- */
325
- put(hash: AttachmentHash, metadata: AttachmentMetadata, data: ReadableStream<Uint8Array>): Promise<void>;
326
- /**
327
- * Evict attachment data to reclaim storage.
328
- *
329
- * Removes the local bytes and sets status to 'evicted'. The
330
- * metadata record is retained so the hash is still known. If the
331
- * data is needed again, the service fetches it via the transport.
332
- *
333
- * Eviction must not destroy data while a get() stream is in
334
- * flight. Implementations must skip hashes with active readers
335
- * (e.g. via a refcount or lease) and revisit them on the next
336
- * GC pass.
337
- *
338
- * On immutable backends, this unpins/stops serving rather
339
- * than deleting.
340
- */
341
- evict(hash: AttachmentHash): Promise<void>;
342
- /**
343
- * Get the total storage used by locally available attachment data.
344
- * Used by the GC policy to decide when to evict.
345
- */
346
- storageUsed(): Promise<number>;
347
- }
348
- /**
349
- * Transport for moving attachment data between reactors.
350
- *
351
- * Forms a bidirectional pair with IAttachmentStore. The store calls
352
- * announce/push when new data arrives locally. The transport calls
353
- * store.put() when data arrives from a remote.
354
- */
355
- interface IAttachmentTransport {
356
- /**
357
- * Fetch attachment data by hash from a remote source.
358
- *
359
- * Returns a three-way discriminated union so callers can distinguish
360
- * "data available", "upload in flight -- retry after expiry", and
361
- * "not found -- possibly permanently". Conflating the last two would
362
- * cause callers to apply long backoff to transient pending state,
363
- * or to retry indefinitely on a permanently missing hash.
364
- *
365
- * @param hash - Content hash of the attachment
366
- * @param signal - Abort signal for cancellation
367
- */
368
- fetch(hash: AttachmentHash, signal?: AbortSignal): Promise<TransportFetchResult>;
369
- /**
370
- * Announce that this reactor has attachment data available.
371
- *
372
- * For server-centric transports, this may be a no-op (the server
373
- * already has the data after upload).
374
- */
375
- announce(hash: AttachmentHash): Promise<void>;
376
- /**
377
- * Push attachment data to a specific remote.
378
- *
379
- * Used for eager replication strategies where the source reactor
380
- * pushes data to known peers rather than waiting for pull requests.
381
- *
382
- * @param hash - Content hash of the attachment
383
- * @param remote - Target remote identifier
384
- * @param data - The attachment data stream
385
- */
386
- push(hash: AttachmentHash, remote: string, data: ReadableStream<Uint8Array>): Promise<void>;
387
- }
388
- /**
389
- * Factory for creating attachment transport instances.
390
- * Mirrors IChannelFactory for operation sync.
391
- */
392
- interface IAttachmentTransportFactory {
393
- instance(config: AttachmentTransportConfig): IAttachmentTransport;
394
- }
395
- /**
396
- * Store for managing attachment reservations.
397
- * Reservations are transient records tracking in-progress uploads.
398
- */
399
- interface IReservationStore {
400
- create(options: ReserveAttachmentOptions): Promise<Reservation>;
401
- get(reservationId: string): Promise<Reservation>;
402
- delete(reservationId: string): Promise<void>;
403
- /**
404
- * Delete reservations whose expires_at_utc is at or before `now`.
405
- * Returns the number of rows deleted.
406
- *
407
- * Reservations are not auto-swept; consumers should call this on a
408
- * cron / interval to clean up rows left behind by aborted uploads.
409
- */
410
- deleteExpired(now?: Date): Promise<number>;
411
- }
412
- /**
413
- * Factory for creating transport-specific upload handles.
414
- * The service calls this during reserve() to create a handle
415
- * that knows how to stream bytes to the appropriate backend.
416
- */
417
- interface IAttachmentUploadFactory {
418
- createUpload(reservation: Reservation): IAttachmentUpload;
419
- }
420
- //#endregion
421
- //#region src/attachment-service.d.ts
422
- declare class AttachmentService implements IAttachmentService {
423
- private readonly store;
424
- private readonly reservations;
425
- private readonly uploadFactory;
426
- constructor(store: IAttachmentReader, reservations: IReservationStore, uploadFactory: IAttachmentUploadFactory);
427
- reserve(options: ReserveAttachmentOptions): Promise<IAttachmentUpload>;
428
- stat(ref: AttachmentRef): Promise<AttachmentHeader>;
429
- get(ref: AttachmentRef, signal?: AbortSignal): Promise<AttachmentResponse>;
430
- private reserveHashFirst;
431
- }
432
- //#endregion
433
- //#region src/errors.d.ts
434
- /**
435
- * Thrown when an attachment ref or hash is not known to the store.
436
- */
437
- declare class AttachmentNotFound extends Error {
438
- constructor(identifier: string);
439
- }
440
- /**
441
- * Thrown when a reservation ID is not found in the reservation store.
442
- */
443
- declare class ReservationNotFound extends Error {
444
- constructor(reservationId: string);
445
- }
446
- /**
447
- * Thrown when an attachment ref string does not match the expected format.
448
- */
449
- declare class InvalidAttachmentRef extends Error {
450
- constructor(ref: string);
451
- }
452
- /**
453
- * Thrown when an upload exceeds the configured maximum byte cap.
454
- * Route handlers should map this to HTTP 413 Payload Too Large.
455
- */
456
- declare class UploadTooLarge extends Error {
457
- readonly maxBytes: number;
458
- constructor(maxBytes: number);
459
- }
460
- /**
461
- * Thrown by reserve() when the claimed hash is already available in the store.
462
- * The caller should use err.ref directly and upload nothing -- this is the
463
- * dedup fast path: duplicate content never leaves the client.
464
- */
465
- declare class AttachmentAlreadyExists extends Error {
466
- readonly hash: AttachmentHash;
467
- readonly ref: AttachmentRef;
468
- constructor(hash: AttachmentHash, ref: AttachmentRef);
469
- }
470
- /**
471
- * Thrown by send() when the server-computed hash of the uploaded bytes
472
- * does not match the hash claimed at reservation time. Nothing is committed;
473
- * the reservation is retained so the client can retry with correct bytes.
474
- */
475
- declare class HashMismatch extends Error {
476
- readonly claimed: AttachmentHash;
477
- readonly actual: AttachmentHash;
478
- constructor(claimed: AttachmentHash, actual: AttachmentHash);
479
- }
480
- /**
481
- * Thrown by send() when the uploaded byte count does not equal the
482
- * sizeBytes declared at reservation time. The handle may reject
483
- * mid-stream as soon as the count exceeds the declaration.
484
- * Nothing is committed; the reservation is retained for retry.
485
- *
486
- * "actual" is the byte count received from the stream before aborting --
487
- * it includes the chunk that crossed the declaration and can exceed bytes
488
- * persisted. On mid-stream aborts the true total is unknown; at least
489
- * "actual" bytes were sent.
490
- */
491
- declare class SizeMismatch extends Error {
492
- readonly declared: number;
493
- readonly actual: number;
494
- constructor(declared: number, actual: number);
495
- }
496
- /**
497
- * Thrown by get() when the hash is reserved by an in-flight upload and
498
- * bytes are not yet available anywhere. Deliberately NOT a subclass of
499
- * AttachmentNotFound -- callers must distinguish "retry later" from "unknown".
500
- * After expiresAtUtc has passed the hash reads as not found.
501
- *
502
- * metadata is populated when the reservation is local and its fields are
503
- * known (mimeType, fileName, sizeBytes). It is undefined when the pending
504
- * state is learned from a remote transport that did not supply the full
505
- * Attachment-Pending header (transport-pending / degraded wire case).
506
- */
507
- declare class AttachmentPending extends Error {
508
- readonly hash: AttachmentHash;
509
- readonly expiresAtUtc: string;
510
- readonly metadata: {
511
- readonly mimeType: string;
512
- readonly fileName: string;
513
- readonly sizeBytes: number;
514
- } | undefined;
515
- constructor(hash: AttachmentHash, expiresAtUtc: string, meta?: {
516
- mimeType: string;
517
- fileName: string;
518
- sizeBytes: number;
519
- });
520
- }
521
- //#endregion
522
- //#region src/ref.d.ts
523
- type ParsedRef = {
524
- version: number;
525
- hash: AttachmentHash;
526
- };
527
- declare function parseRef(ref: AttachmentRef): ParsedRef;
528
- declare function createRef(hash: AttachmentHash, version?: number): AttachmentRef;
529
- //#endregion
530
- //#region src/switchboard/switchboard-attachment-transport.d.ts
531
- type SwitchboardTransportConfig = {
532
- remoteUrl: string;
533
- jwtHandler?: JwtHandler;
534
- fetchFn?: typeof fetch;
535
- };
536
- declare class SwitchboardAttachmentTransport implements IAttachmentTransport {
537
- private readonly remoteUrl;
538
- private readonly jwtHandler?;
539
- private readonly fetchFn;
540
- constructor(config: SwitchboardTransportConfig);
541
- fetch(hash: AttachmentHash, signal?: AbortSignal): Promise<TransportFetchResult>;
542
- announce(_hash: AttachmentHash): Promise<void>;
543
- push(hash: AttachmentHash, remote: string, data: ReadableStream<Uint8Array>): Promise<void>;
544
- private parsePendingExpiry;
545
- private parseMetadataHeaders;
546
- }
547
- //#endregion
548
- //#region src/switchboard/remote-reservation-store.d.ts
549
- type SwitchboardClientConfig = {
550
- remoteUrl: string;
551
- jwtHandler?: JwtHandler;
552
- fetchFn?: typeof fetch;
553
- };
554
- declare class RemoteReservationStore implements IReservationStore {
555
- private readonly remoteUrl;
556
- private readonly jwtHandler?;
557
- private readonly fetchFn;
558
- constructor(config: SwitchboardClientConfig);
559
- create(options: ReserveAttachmentOptions): Promise<Reservation>;
560
- get(reservationId: string): Promise<Reservation>;
561
- delete(reservationId: string): Promise<void>;
562
- deleteExpired(): Promise<number>;
563
- }
564
- //#endregion
565
- //#region src/switchboard/remote-attachment-upload.d.ts
566
- declare class RemoteAttachmentUpload implements IAttachmentUpload {
567
- readonly reservationId: string;
568
- readonly ref: AttachmentRef | null;
569
- readonly expiresAtUtc: string;
570
- private readonly remoteUrl;
571
- private readonly jwtHandler?;
572
- private readonly fetchFn;
573
- constructor(reservation: Reservation, config: SwitchboardClientConfig);
574
- send(data: ReadableStream<Uint8Array>): Promise<AttachmentUploadResult>;
575
- }
576
- //#endregion
577
- //#region src/switchboard/remote-attachment-upload-factory.d.ts
578
- declare class RemoteAttachmentUploadFactory implements IAttachmentUploadFactory {
579
- private readonly config;
580
- constructor(config: SwitchboardClientConfig);
581
- createUpload(reservation: Reservation): IAttachmentUpload;
582
- }
583
- //#endregion
584
- //#region src/switchboard/remote-attachment-store.d.ts
585
- declare class RemoteAttachmentStore implements IAttachmentReader {
586
- private readonly remoteUrl;
587
- private readonly jwtHandler?;
588
- private readonly fetchFn;
589
- constructor(config: SwitchboardClientConfig);
590
- /**
591
- * Get attachment metadata. Normally returns a pending AttachmentHeader
592
- * (status: 'pending') when the server responds 202 with a full
593
- * Attachment-Pending header. When only expiresAtUtc is present in the
594
- * header (degraded wire), throws AttachmentPending instead -- the
595
- * AttachmentPending throw is the degraded-wire case.
596
- */
597
- stat(hash: AttachmentHash): Promise<AttachmentHeader>;
598
- get(hash: AttachmentHash, signal?: AbortSignal): Promise<AttachmentResponse>;
599
- private fetchAttachment;
600
- }
601
- //#endregion
602
- //#region src/switchboard/create-remote-attachment-service.d.ts
603
- declare function createRemoteAttachmentService(config: SwitchboardClientConfig): IAttachmentService;
604
- //#endregion
605
- //#region src/null-attachment-transport.d.ts
606
- /**
607
- * No-op transport for deployments without remote sync.
608
- * fetch() always returns not-found, announce() and push() are no-ops.
609
- */
610
- declare class NullAttachmentTransport implements IAttachmentTransport {
611
- fetch(): Promise<TransportFetchResult>;
612
- announce(): Promise<void>;
613
- push(): Promise<void>;
614
- }
615
- //#endregion
616
4
  //#region src/client.d.ts
617
5
  type PreprocessResult = {
618
6
  ref: AttachmentRef;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","names":[],"sources":["../src/types.ts","../src/interfaces.ts","../src/attachment-service.ts","../src/errors.ts","../src/ref.ts","../src/switchboard/switchboard-attachment-transport.ts","../src/switchboard/remote-reservation-store.ts","../src/switchboard/remote-attachment-upload.ts","../src/switchboard/remote-attachment-upload-factory.ts","../src/switchboard/remote-attachment-store.ts","../src/switchboard/create-remote-attachment-service.ts","../src/null-attachment-transport.ts","../src/client.ts"],"mappings":";;;;;AAOA;;;KAAY,gBAAA;;AAQZ;;;;;KAAY,gBAAA;EACV,IAAA,EAAM,cAAA;EACN,QAAA;EACA,QAAA;EACA,SAAA;EACA,SAAA;EACA,MAAA,EAAQ,gBAAA;EACR,MAAA;EACA,YAAA;EACA,iBAAA;EACA,YAAA;AAAA;;AAsBF;;;;;;;;;;;;AAaA;;;;;;KAbY,kBAAA;EACV,QAAA;EACA,QAAA;EACA,SAAA;EACA,SAAA;EACA,YAAA;EACA,iBAAA;AAAA;;;;;KAOU,mCAAA;EACV,QAAA;EACA,QAAA;EACA,SAAA;EACA,UAAA;EACA,SAAA;AAAA;;;;AA2CF;;;;KAjCY,iCAAA;EACV,QAAA;EACA,QAAA;EACA,SAAA;EA+BA;;;EA3BA,UAAA,EAAY,cAAA;EA6BZ;;;;AAMF;EA7BE,SAAA;AAAA;;;;;;;;;;;KAaU,wBAAA,GACR,mCAAA,GACA,iCAAA;;AAyBJ;;KApBY,sBAAA;EACV,IAAA,EAAM,cAAA;EACN,GAAA,EAAK,aAAA;EACL,MAAA,EAAQ,gBAAA;AAAA;;;;KAME,kBAAA;EACV,MAAA,EAAQ,gBAAA;EACR,IAAA,EAA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