@powerhousedao/reactor-attachments 6.2.3-dev.6 → 6.2.3-dev.61
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/attachment-schema-compiler-rIaJpiHO.js +262 -0
- package/dist/attachment-schema-compiler-rIaJpiHO.js.map +1 -0
- package/dist/client.d.ts +56 -36
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +33 -20
- package/dist/client.js.map +1 -1
- package/dist/hash-BobbR4r4.js +63 -0
- package/dist/hash-BobbR4r4.js.map +1 -0
- package/dist/index.d.ts +81 -111
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -405
- package/dist/index.js.map +1 -1
- package/dist/{null-attachment-transport-CMrO_ZKA.d.ts → interfaces-C4GRlKeB.d.ts} +34 -327
- package/dist/interfaces-C4GRlKeB.d.ts.map +1 -0
- package/dist/null-attachment-transport-Bs4JpmFx.d.ts +327 -0
- package/dist/null-attachment-transport-Bs4JpmFx.d.ts.map +1 -0
- package/dist/{null-attachment-transport-CrsUafCi.js → null-attachment-transport-Cm_kb5ww.js} +37 -283
- package/dist/null-attachment-transport-Cm_kb5ww.js.map +1 -0
- package/dist/replication.d.ts +955 -0
- package/dist/replication.d.ts.map +1 -0
- package/dist/replication.js +1975 -0
- package/dist/replication.js.map +1 -0
- package/dist/switchboard-attachment-transport-BH3ZAmxE.js +284 -0
- package/dist/switchboard-attachment-transport-BH3ZAmxE.js.map +1 -0
- package/dist/types-AagIcjTD.d.ts +61 -0
- package/dist/types-AagIcjTD.d.ts.map +1 -0
- package/package.json +16 -7
- package/dist/null-attachment-transport-CMrO_ZKA.d.ts.map +0 -1
- package/dist/null-attachment-transport-CrsUafCi.js.map +0 -1
|
@@ -1,105 +1,4 @@
|
|
|
1
|
-
import { AttachmentHash, AttachmentRef
|
|
2
|
-
|
|
3
|
-
//#region src/errors.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Thrown when an attachment ref or hash is not known to the store.
|
|
6
|
-
*/
|
|
7
|
-
declare class AttachmentNotFound extends Error {
|
|
8
|
-
constructor(identifier: string);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Thrown when a reservation ID is not found in the reservation store.
|
|
12
|
-
*/
|
|
13
|
-
declare class ReservationNotFound extends Error {
|
|
14
|
-
constructor(reservationId: string);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Thrown when an attachment ref string does not match the expected format.
|
|
18
|
-
*/
|
|
19
|
-
declare class InvalidAttachmentRef extends Error {
|
|
20
|
-
constructor(ref: string);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Thrown when an upload exceeds the configured maximum byte cap.
|
|
24
|
-
* Route handlers should map this to HTTP 413 Payload Too Large.
|
|
25
|
-
*/
|
|
26
|
-
declare class UploadTooLarge extends Error {
|
|
27
|
-
readonly maxBytes: number;
|
|
28
|
-
constructor(maxBytes: number);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Thrown by reserve() when the claimed hash is already available in the store.
|
|
32
|
-
* The caller should use err.ref directly and upload nothing -- this is the
|
|
33
|
-
* dedup fast path: duplicate content never leaves the client.
|
|
34
|
-
*/
|
|
35
|
-
declare class AttachmentAlreadyExists extends Error {
|
|
36
|
-
readonly hash: AttachmentHash;
|
|
37
|
-
readonly ref: AttachmentRef;
|
|
38
|
-
constructor(hash: AttachmentHash, ref: AttachmentRef);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Thrown by send() when the server-computed hash of the uploaded bytes
|
|
42
|
-
* does not match the hash claimed at reservation time. Nothing is committed;
|
|
43
|
-
* the reservation is retained so the client can retry with correct bytes.
|
|
44
|
-
*/
|
|
45
|
-
declare class HashMismatch extends Error {
|
|
46
|
-
readonly claimed: AttachmentHash;
|
|
47
|
-
readonly actual: AttachmentHash;
|
|
48
|
-
constructor(claimed: AttachmentHash, actual: AttachmentHash);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Thrown by send() when the uploaded byte count does not equal the
|
|
52
|
-
* sizeBytes declared at reservation time. The handle may reject
|
|
53
|
-
* mid-stream as soon as the count exceeds the declaration.
|
|
54
|
-
* Nothing is committed; the reservation is retained for retry.
|
|
55
|
-
*
|
|
56
|
-
* "actual" is the byte count received from the stream before aborting --
|
|
57
|
-
* it includes the chunk that crossed the declaration and can exceed bytes
|
|
58
|
-
* persisted. On mid-stream aborts the true total is unknown; at least
|
|
59
|
-
* "actual" bytes were sent.
|
|
60
|
-
*/
|
|
61
|
-
declare class SizeMismatch extends Error {
|
|
62
|
-
readonly declared: number;
|
|
63
|
-
readonly actual: number;
|
|
64
|
-
constructor(declared: number, actual: number);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Thrown by get() when the hash is reserved by an in-flight upload and
|
|
68
|
-
* bytes are not yet available anywhere. Deliberately NOT a subclass of
|
|
69
|
-
* AttachmentNotFound -- callers must distinguish "retry later" from "unknown".
|
|
70
|
-
* After expiresAtUtc has passed the hash reads as not found.
|
|
71
|
-
*
|
|
72
|
-
* metadata is populated when the reservation is local and its fields are
|
|
73
|
-
* known (mimeType, fileName, sizeBytes). It is undefined when the pending
|
|
74
|
-
* state is learned from a remote transport that did not supply the full
|
|
75
|
-
* Attachment-Pending header (transport-pending / degraded wire case).
|
|
76
|
-
*/
|
|
77
|
-
type AttachmentTransferStage = "download-target" | "switchboard-get" | "presigned-get" | "presigned-put";
|
|
78
|
-
/**
|
|
79
|
-
* Thrown when a remote transfer step fails. Identifies the stage only; it
|
|
80
|
-
* intentionally carries no URL, signature query, bucket key, or bearer
|
|
81
|
-
* material so it is always safe to log or surface.
|
|
82
|
-
*/
|
|
83
|
-
declare class AttachmentTransferError extends Error {
|
|
84
|
-
readonly stage: AttachmentTransferStage;
|
|
85
|
-
readonly status: number | undefined;
|
|
86
|
-
constructor(stage: AttachmentTransferStage, status?: number);
|
|
87
|
-
}
|
|
88
|
-
declare class AttachmentPending extends Error {
|
|
89
|
-
readonly hash: AttachmentHash;
|
|
90
|
-
readonly expiresAtUtc: string;
|
|
91
|
-
readonly metadata: {
|
|
92
|
-
readonly mimeType: string;
|
|
93
|
-
readonly fileName: string;
|
|
94
|
-
readonly sizeBytes: number;
|
|
95
|
-
} | undefined;
|
|
96
|
-
constructor(hash: AttachmentHash, expiresAtUtc: string, meta?: {
|
|
97
|
-
mimeType: string;
|
|
98
|
-
fileName: string;
|
|
99
|
-
sizeBytes: number;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
1
|
+
import { AttachmentHash, AttachmentRef } from "@powerhousedao/reactor";
|
|
103
2
|
//#region src/types.d.ts
|
|
104
3
|
type AttachmentBackendKind = "filesystem" | "s3";
|
|
105
4
|
type AttachmentBackendHealth = {
|
|
@@ -230,6 +129,10 @@ type AttachmentDownloadOptions = {
|
|
|
230
129
|
documentId?: string;
|
|
231
130
|
signal?: AbortSignal;
|
|
232
131
|
};
|
|
132
|
+
/** Options form of IAttachmentService.stat. */
|
|
133
|
+
type AttachmentStatOptions = {
|
|
134
|
+
documentId?: string;
|
|
135
|
+
};
|
|
233
136
|
/**
|
|
234
137
|
* Options for minting a raw download target without transferring bytes
|
|
235
138
|
* (previews, share links). `documentId` is required: targets are always
|
|
@@ -307,6 +210,10 @@ type TransportFetchResult = {
|
|
|
307
210
|
hash: AttachmentHash;
|
|
308
211
|
expiresAtUtc: string;
|
|
309
212
|
retryAfterMs: number;
|
|
213
|
+
/** The source is at capacity and did not look; not a reservation. */
|
|
214
|
+
busy?: true;
|
|
215
|
+
/** With `busy`: every source that was not busy answered not-found. */
|
|
216
|
+
othersNotFound?: true;
|
|
310
217
|
} | {
|
|
311
218
|
kind: "not-found";
|
|
312
219
|
};
|
|
@@ -373,8 +280,11 @@ interface IAttachmentService {
|
|
|
373
280
|
* Returns an AttachmentHeader with status='pending' and expiresAtUtc set if
|
|
374
281
|
* the hash has an active reservation but no committed bytes. Callers must
|
|
375
282
|
* check header.status to distinguish pending from available.
|
|
283
|
+
*
|
|
284
|
+
* `documentId` names the document that authorizes the read. Remote readers
|
|
285
|
+
* require it; local/direct readers ignore it.
|
|
376
286
|
*/
|
|
377
|
-
stat(ref: AttachmentRef): Promise<AttachmentHeader>;
|
|
287
|
+
stat(ref: AttachmentRef, options?: AttachmentStatOptions): Promise<AttachmentHeader>;
|
|
378
288
|
/**
|
|
379
289
|
* Retrieve attachment data.
|
|
380
290
|
*
|
|
@@ -389,8 +299,7 @@ interface IAttachmentService {
|
|
|
389
299
|
* callers cannot tune it.
|
|
390
300
|
*
|
|
391
301
|
* The options form carries the document id that authorizes a remote
|
|
392
|
-
* download; local/direct readers ignore it.
|
|
393
|
-
* supported for source compatibility.
|
|
302
|
+
* download. Remote readers require it; local/direct readers ignore it.
|
|
394
303
|
*/
|
|
395
304
|
get(ref: AttachmentRef, options?: AbortSignal | AttachmentDownloadOptions): Promise<AttachmentResponse>;
|
|
396
305
|
/**
|
|
@@ -431,6 +340,9 @@ interface IAttachmentUpload {
|
|
|
431
340
|
/**
|
|
432
341
|
* Stream attachment data through this handle.
|
|
433
342
|
*
|
|
343
|
+
* `data` may be a Blob: a remote handle sends it as the request body
|
|
344
|
+
* as-is, which a browser streams from disk instead of buffering.
|
|
345
|
+
*
|
|
434
346
|
* The handle manages the full upload lifecycle internally:
|
|
435
347
|
* writing bytes to the backing store, computing or verifying
|
|
436
348
|
* the content hash, creating the attachment record, and
|
|
@@ -462,7 +374,7 @@ interface IAttachmentUpload {
|
|
|
462
374
|
* upload as done. A handle that transfers nothing itself (the S3 handle,
|
|
463
375
|
* which requires its presigned target) has nothing to abort.
|
|
464
376
|
*/
|
|
465
|
-
send(data: ReadableStream<Uint8Array
|
|
377
|
+
send(data: ReadableStream<Uint8Array> | Blob, options?: AttachmentSendOptions): Promise<AttachmentUploadResult>;
|
|
466
378
|
}
|
|
467
379
|
/**
|
|
468
380
|
* Read-only subset of IAttachmentStore.
|
|
@@ -483,16 +395,19 @@ interface IAttachmentReader {
|
|
|
483
395
|
* Returns an AttachmentHeader with status='pending' and expiresAtUtc set if
|
|
484
396
|
* the hash has an active reservation but no committed bytes. Callers must
|
|
485
397
|
* check header.status to distinguish pending from available.
|
|
398
|
+
*
|
|
399
|
+
* `documentId` is the authorization anchor: remote readers require it,
|
|
400
|
+
* local/direct readers ignore it.
|
|
486
401
|
*/
|
|
487
|
-
stat(hash: AttachmentHash): Promise<AttachmentHeader>;
|
|
402
|
+
stat(hash: AttachmentHash, documentId?: string): Promise<AttachmentHeader>;
|
|
488
403
|
/**
|
|
489
404
|
* Retrieve attachment header and data stream by hash.
|
|
490
405
|
* Updates lastAccessedAtUtc on access.
|
|
491
406
|
*
|
|
492
|
-
* If the data has been evicted, re-fetches it from the
|
|
493
|
-
* restores it locally via put(), and
|
|
494
|
-
*
|
|
495
|
-
*
|
|
407
|
+
* If the data has been evicted or was never local, re-fetches it from the
|
|
408
|
+
* transport on behalf of `documentId`, restores it locally via put(), and
|
|
409
|
+
* returns the data. Without a `documentId` there is nothing to authorize
|
|
410
|
+
* the remote fetch, so only locally available bytes are served.
|
|
496
411
|
*
|
|
497
412
|
* @throws AttachmentNotFound if the hash is unknown (no metadata
|
|
498
413
|
* record exists and no pending reservation).
|
|
@@ -500,8 +415,8 @@ interface IAttachmentReader {
|
|
|
500
415
|
* upload; bytes are not yet available. There is no store-level
|
|
501
416
|
* wait -- polling is the caller's responsibility.
|
|
502
417
|
*
|
|
503
|
-
* `documentId` is the authorization anchor
|
|
504
|
-
*
|
|
418
|
+
* `documentId` is the authorization anchor: remote readers require it,
|
|
419
|
+
* and local stores pass it to the transport when they must re-fetch.
|
|
505
420
|
*/
|
|
506
421
|
get(hash: AttachmentHash, signal?: AbortSignal, documentId?: string): Promise<AttachmentResponse>;
|
|
507
422
|
/**
|
|
@@ -577,9 +492,11 @@ interface IAttachmentTransport {
|
|
|
577
492
|
* or to retry indefinitely on a permanently missing hash.
|
|
578
493
|
*
|
|
579
494
|
* @param hash - Content hash of the attachment
|
|
495
|
+
* @param documentId - Document whose operations reference the attachment;
|
|
496
|
+
* the remote authorizes the fetch through it
|
|
580
497
|
* @param signal - Abort signal for cancellation
|
|
581
498
|
*/
|
|
582
|
-
fetch(hash: AttachmentHash, signal?: AbortSignal): Promise<TransportFetchResult>;
|
|
499
|
+
fetch(hash: AttachmentHash, documentId: string, signal?: AbortSignal): Promise<TransportFetchResult>;
|
|
583
500
|
/**
|
|
584
501
|
* Announce that this reactor has attachment data available.
|
|
585
502
|
*
|
|
@@ -649,216 +566,6 @@ interface IAttachmentBackend {
|
|
|
649
566
|
health(): Promise<AttachmentBackendHealth>;
|
|
650
567
|
}
|
|
651
568
|
//#endregion
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
//#endregion
|
|
656
|
-
//#region src/attachment-service.d.ts
|
|
657
|
-
declare class AttachmentService implements IAttachmentService {
|
|
658
|
-
private readonly store;
|
|
659
|
-
private readonly reservations;
|
|
660
|
-
private readonly uploadFactory;
|
|
661
|
-
private readonly backend?;
|
|
662
|
-
constructor(store: IAttachmentReader, reservations: IReservationStore, uploadFactory: IAttachmentUploadFactory, backend?: IAttachmentBackend | undefined);
|
|
663
|
-
reserve(options: ReserveAttachmentOptions): Promise<IAttachmentUpload>;
|
|
664
|
-
stat(ref: AttachmentRef): Promise<AttachmentHeader>;
|
|
665
|
-
get(ref: AttachmentRef, options?: AbortSignal | AttachmentDownloadOptions): Promise<AttachmentResponse>;
|
|
666
|
-
getDownloadTarget(ref: AttachmentRef, options: AttachmentDownloadTargetOptions): Promise<AttachmentDownloadTarget>;
|
|
667
|
-
private reserveHashFirst;
|
|
668
|
-
}
|
|
669
|
-
//#endregion
|
|
670
|
-
//#region src/ref.d.ts
|
|
671
|
-
type ParsedRef = {
|
|
672
|
-
version: number;
|
|
673
|
-
hash: AttachmentHash;
|
|
674
|
-
};
|
|
675
|
-
declare function parseRef(ref: AttachmentRef): ParsedRef;
|
|
676
|
-
declare function createRef(hash: AttachmentHash, version?: number): AttachmentRef;
|
|
677
|
-
//#endregion
|
|
678
|
-
//#region src/switchboard/switchboard-attachment-transport.d.ts
|
|
679
|
-
type SwitchboardTransportConfig = {
|
|
680
|
-
remoteUrl: string;
|
|
681
|
-
jwtHandler?: JwtHandler;
|
|
682
|
-
fetchFn?: typeof fetch;
|
|
683
|
-
};
|
|
684
|
-
declare class SwitchboardAttachmentTransport implements IAttachmentTransport {
|
|
685
|
-
private readonly remoteUrl;
|
|
686
|
-
private readonly jwtHandler?;
|
|
687
|
-
private readonly fetchFn;
|
|
688
|
-
constructor(config: SwitchboardTransportConfig);
|
|
689
|
-
fetch(hash: AttachmentHash, signal?: AbortSignal): Promise<TransportFetchResult>;
|
|
690
|
-
announce(_hash: AttachmentHash): Promise<void>;
|
|
691
|
-
push(hash: AttachmentHash, remote: string, data: ReadableStream<Uint8Array>): Promise<void>;
|
|
692
|
-
private parsePendingExpiry;
|
|
693
|
-
private parseMetadataHeaders;
|
|
694
|
-
}
|
|
695
|
-
//#endregion
|
|
696
|
-
//#region src/switchboard/upload-transport.d.ts
|
|
697
|
-
/**
|
|
698
|
-
* The seam every attachment upload PUT goes through.
|
|
699
|
-
*
|
|
700
|
-
* It exists because `fetch` cannot report upload-side progress: there is no
|
|
701
|
-
* event between "request issued" and "response received". Naming the transport
|
|
702
|
-
* lets an implementation that *can* count bytes (see
|
|
703
|
-
* `createXhrUploadTransport`) be substituted without the upload code knowing
|
|
704
|
-
* which one it holds — and it is also the right seam for a future multipart
|
|
705
|
-
* upload, which needs one request per part.
|
|
706
|
-
*/
|
|
707
|
-
/**
|
|
708
|
-
* Headers are forwarded VERBATIM. A presigned target's headers are part of a
|
|
709
|
-
* signature: normalizing their casing, or adding so much as one header,
|
|
710
|
-
* invalidates it.
|
|
711
|
-
*/
|
|
712
|
-
type AttachmentUploadRequest = {
|
|
713
|
-
url: string;
|
|
714
|
-
method: "PUT";
|
|
715
|
-
headers: Record<string, string>;
|
|
716
|
-
body: Blob; /** Called with cumulative bytes handed to the socket, when observable. */
|
|
717
|
-
onProgress?: (loaded: number, total: number) => void;
|
|
718
|
-
signal?: AbortSignal;
|
|
719
|
-
};
|
|
720
|
-
/**
|
|
721
|
-
* The only response surface the upload code reads. A real `Response`
|
|
722
|
-
* satisfies this structurally, which is what lets the fetch transport be an
|
|
723
|
-
* identity pass-through rather than an adapter.
|
|
724
|
-
*/
|
|
725
|
-
type AttachmentUploadResponse = {
|
|
726
|
-
readonly status: number;
|
|
727
|
-
readonly statusText: string;
|
|
728
|
-
readonly ok: boolean;
|
|
729
|
-
json(): Promise<unknown>;
|
|
730
|
-
};
|
|
731
|
-
type AttachmentUploadTransport = (request: AttachmentUploadRequest) => Promise<AttachmentUploadResponse>;
|
|
732
|
-
/**
|
|
733
|
-
* The default transport. Ignores `onProgress` — fetch has no upload-side
|
|
734
|
-
* progress event, and silence is how a transport reports that bytes are
|
|
735
|
-
* unobservable.
|
|
736
|
-
*/
|
|
737
|
-
declare function createFetchUploadTransport(fetchFn: typeof fetch): AttachmentUploadTransport;
|
|
738
|
-
//#endregion
|
|
739
|
-
//#region src/switchboard/xhr-upload-transport.d.ts
|
|
740
|
-
type XhrUploadTransportOptions = {
|
|
741
|
-
/**
|
|
742
|
-
* Used where `XMLHttpRequest` does not exist (Node). Defaults to the global
|
|
743
|
-
* fetch, resolved at call time.
|
|
744
|
-
*/
|
|
745
|
-
fetchFn?: typeof fetch;
|
|
746
|
-
};
|
|
747
|
-
/**
|
|
748
|
-
* Upload transport backed by `XMLHttpRequest`, the only browser API that
|
|
749
|
-
* reports upload-side byte progress (`xhr.upload.onprogress`). Everything else
|
|
750
|
-
* about the request is identical to the fetch path.
|
|
751
|
-
*
|
|
752
|
-
* Capability detection happens **inside** the returned function, never at
|
|
753
|
-
* module load: this module is reachable from the client entry, which is
|
|
754
|
-
* executed in Node by the entrypoint tests, and Node has no
|
|
755
|
-
* `XMLHttpRequest`. Detecting per call also means a test can install a fake on
|
|
756
|
-
* `globalThis` without any module-registry reset.
|
|
757
|
-
*/
|
|
758
|
-
declare function createXhrUploadTransport(options?: XhrUploadTransportOptions): AttachmentUploadTransport;
|
|
759
|
-
//#endregion
|
|
760
|
-
//#region src/switchboard/remote-reservation-store.d.ts
|
|
761
|
-
type SwitchboardClientConfig = {
|
|
762
|
-
remoteUrl: string;
|
|
763
|
-
jwtHandler?: JwtHandler;
|
|
764
|
-
fetchFn?: typeof fetch;
|
|
765
|
-
/**
|
|
766
|
-
* Transport for upload PUTs only, so a browser host can opt into
|
|
767
|
-
* XMLHttpRequest and get real upload progress.
|
|
768
|
-
*
|
|
769
|
-
* An explicit `fetchFn` always wins over this. The precedence is
|
|
770
|
-
* one-directional on purpose: under this rule, adding `uploadTransport` to a
|
|
771
|
-
* config that already pins `fetchFn` is a provable no-op, whereas the
|
|
772
|
-
* reverse rule would let `{ ...config, uploadTransport }` silently route the
|
|
773
|
-
* largest request in the system around a test's mock and onto the network.
|
|
774
|
-
*/
|
|
775
|
-
uploadTransport?: AttachmentUploadTransport;
|
|
776
|
-
};
|
|
777
|
-
declare class RemoteReservationStore implements IReservationStore {
|
|
778
|
-
private readonly remoteUrl;
|
|
779
|
-
private readonly jwtHandler?;
|
|
780
|
-
private readonly fetchFn;
|
|
781
|
-
constructor(config: SwitchboardClientConfig);
|
|
782
|
-
create(options: ReserveAttachmentOptions): Promise<Reservation>;
|
|
783
|
-
get(reservationId: string): Promise<Reservation>;
|
|
784
|
-
delete(reservationId: string): Promise<void>;
|
|
785
|
-
deleteExpired(): Promise<number>;
|
|
786
|
-
}
|
|
787
|
-
//#endregion
|
|
788
|
-
//#region src/switchboard/remote-attachment-upload.d.ts
|
|
789
|
-
declare class RemoteAttachmentUpload implements IAttachmentUpload {
|
|
790
|
-
readonly reservationId: string;
|
|
791
|
-
readonly ref: AttachmentRef | null;
|
|
792
|
-
readonly expiresAtUtc: string;
|
|
793
|
-
readonly uploadTarget?: AttachmentUploadTarget;
|
|
794
|
-
private readonly reservation;
|
|
795
|
-
private readonly remoteUrl;
|
|
796
|
-
private readonly jwtHandler?;
|
|
797
|
-
private readonly uploadTransport;
|
|
798
|
-
constructor(reservation: Reservation, config: SwitchboardClientConfig);
|
|
799
|
-
send(data: ReadableStream<Uint8Array>, options?: AttachmentSendOptions): Promise<AttachmentUploadResult>;
|
|
800
|
-
/**
|
|
801
|
-
* Direct provider upload: PUT the bytes to the presigned URL with exactly
|
|
802
|
-
* the returned headers — never the Switchboard JWT — and treat any 2xx as
|
|
803
|
-
* final success with no follow-up control request. The result is
|
|
804
|
-
* synthesized from the hash-first reservation, which is the only path that
|
|
805
|
-
* can produce a presigned target.
|
|
806
|
-
*/
|
|
807
|
-
private sendPresigned;
|
|
808
|
-
}
|
|
809
|
-
//#endregion
|
|
810
|
-
//#region src/switchboard/remote-attachment-upload-factory.d.ts
|
|
811
|
-
declare class RemoteAttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
812
|
-
private readonly config;
|
|
813
|
-
constructor(config: SwitchboardClientConfig);
|
|
814
|
-
createUpload(reservation: Reservation): IAttachmentUpload;
|
|
815
|
-
}
|
|
816
|
-
//#endregion
|
|
817
|
-
//#region src/switchboard/remote-attachment-store.d.ts
|
|
818
|
-
declare class RemoteAttachmentStore implements IAttachmentReader {
|
|
819
|
-
private readonly remoteUrl;
|
|
820
|
-
private readonly jwtHandler?;
|
|
821
|
-
private readonly fetchFn;
|
|
822
|
-
constructor(config: SwitchboardClientConfig);
|
|
823
|
-
/**
|
|
824
|
-
* Get attachment metadata. Normally returns a pending AttachmentHeader
|
|
825
|
-
* (status: 'pending') when the server responds 202 with a full
|
|
826
|
-
* Attachment-Pending header. When only expiresAtUtc is present in the
|
|
827
|
-
* header (degraded wire), throws AttachmentPending instead -- the
|
|
828
|
-
* AttachmentPending throw is the degraded-wire case.
|
|
829
|
-
*/
|
|
830
|
-
stat(hash: AttachmentHash): Promise<AttachmentHeader>;
|
|
831
|
-
get(hash: AttachmentHash, signal?: AbortSignal, documentId?: string): Promise<AttachmentResponse>;
|
|
832
|
-
/**
|
|
833
|
-
* Asks Switchboard for an authorized download target. The request carries
|
|
834
|
-
* the JWT; the response is runtime-validated before any byte transfer.
|
|
835
|
-
* Public so callers can mint direct URLs (previews, share links) without
|
|
836
|
-
* transferring bytes; `expiresIn` requests a caller-chosen lifetime.
|
|
837
|
-
*/
|
|
838
|
-
getDownloadTarget(hash: AttachmentHash, options: AttachmentDownloadTargetOptions): Promise<AttachmentDownloadTarget>;
|
|
839
|
-
/**
|
|
840
|
-
* Executes a presigned GET with exactly the returned headers and no JWT.
|
|
841
|
-
* A provider 404 means the object is missing despite available metadata
|
|
842
|
-
* (the accepted abandoned-upload trade-off) and surfaces as the same typed
|
|
843
|
-
* not-found error callers already handle.
|
|
844
|
-
*/
|
|
845
|
-
private fetchPresigned;
|
|
846
|
-
private fetchAttachment;
|
|
847
|
-
}
|
|
848
|
-
//#endregion
|
|
849
|
-
//#region src/switchboard/create-remote-attachment-service.d.ts
|
|
850
|
-
declare function createRemoteAttachmentService(config: SwitchboardClientConfig): IAttachmentService;
|
|
851
|
-
//#endregion
|
|
852
|
-
//#region src/null-attachment-transport.d.ts
|
|
853
|
-
/**
|
|
854
|
-
* No-op transport for deployments without remote sync.
|
|
855
|
-
* fetch() always returns not-found, announce() and push() are no-ops.
|
|
856
|
-
*/
|
|
857
|
-
declare class NullAttachmentTransport implements IAttachmentTransport {
|
|
858
|
-
fetch(): Promise<TransportFetchResult>;
|
|
859
|
-
announce(): Promise<void>;
|
|
860
|
-
push(): Promise<void>;
|
|
861
|
-
}
|
|
862
|
-
//#endregion
|
|
863
|
-
export { AttachmentPending as $, IReservationStore as A, AttachmentStatus as B, IAttachmentReader as C, IAttachmentTransportFactory as D, IAttachmentTransport as E, AttachmentDownloadTargetOptions as F, HashFirstReserveAttachmentOptions as G, AttachmentTransportConfig as H, AttachmentHeader as I, TransportFetchResult as J, Reservation as K, AttachmentMetadata as L, AttachmentBackendKind as M, AttachmentDownloadOptions as N, IAttachmentUpload as O, AttachmentDownloadTarget as P, AttachmentNotFound as Q, AttachmentResponse as R, IAttachmentBackend as S, IAttachmentStore as T, AttachmentUploadResult as U, AttachmentTargetHeaders as V, AttachmentUploadTarget as W, UploadFirstReserveAttachmentOptions as X, TransportResponse as Y, AttachmentAlreadyExists as Z, createRef as _, RemoteAttachmentUpload as a, SizeMismatch as at, parseAttachmentDownloadTarget as b, XhrUploadTransportOptions as c, AttachmentUploadResponse as d, AttachmentTransferError as et, AttachmentUploadTransport as f, ParsedRef as g, SwitchboardTransportConfig as h, RemoteAttachmentUploadFactory as i, ReservationNotFound as it, AttachmentBackendHealth as j, IAttachmentUploadFactory as k, createXhrUploadTransport as l, SwitchboardAttachmentTransport as m, createRemoteAttachmentService as n, HashMismatch as nt, RemoteReservationStore as o, UploadTooLarge as ot, createFetchUploadTransport as p, ReserveAttachmentOptions as q, RemoteAttachmentStore as r, InvalidAttachmentRef as rt, SwitchboardClientConfig as s, NullAttachmentTransport as t, AttachmentTransferStage as tt, AttachmentUploadRequest as u, parseRef as v, IAttachmentService as w, parseAttachmentUploadTarget as x, AttachmentService as y, AttachmentSendOptions as z };
|
|
864
|
-
//# sourceMappingURL=null-attachment-transport-CMrO_ZKA.d.ts.map
|
|
569
|
+
export { UploadFirstReserveAttachmentOptions as A, AttachmentUploadResult as C, ReserveAttachmentOptions as D, Reservation as E, TransportFetchResult as O, AttachmentTransportConfig as S, HashFirstReserveAttachmentOptions as T, AttachmentResponse as _, IAttachmentTransport as a, AttachmentStatus as b, IAttachmentUploadFactory as c, AttachmentBackendKind as d, AttachmentDownloadOptions as f, AttachmentMetadata as g, AttachmentHeader as h, IAttachmentStore as i, TransportResponse as k, IReservationStore as l, AttachmentDownloadTargetOptions as m, IAttachmentReader as n, IAttachmentTransportFactory as o, AttachmentDownloadTarget as p, IAttachmentService as r, IAttachmentUpload as s, IAttachmentBackend as t, AttachmentBackendHealth as u, AttachmentSendOptions as v, AttachmentUploadTarget as w, AttachmentTargetHeaders as x, AttachmentStatOptions as y };
|
|
570
|
+
export {};
|
|
571
|
+
//# sourceMappingURL=interfaces-C4GRlKeB.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces-C4GRlKeB.d.ts","names":[],"sources":["../src/types.ts","../src/interfaces.ts"],"mappings":";;KAEY;KAEA;EACV,MAAM;EACN;;;;;;;KAQU;;;;;;;KAQA;EACV,MAAM;EACN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;;;;;;;;;;;;;;;;;;;;;KAsBU;EACV;EACA;EACA;EACA;EACA;EACA;;;;;;KAOU;EACV;EACA;EACA;EACA;EACA;;;;;;;;;KAUU;EACV;EACA;EACA;;;;EAIA,YAAY;;;;;;EAMZ;;;;;;;;;;;;KAaU,2BACR,sCACA;;;;KAKQ;EACV,MAAM;EACN,KAAK;EACL,QAAQ;;;;;;;;;;KAWE;EACV,cAAc,gBAAgB;EAC9B,SAAS;;;;;;;KAQC;EACV;EACA,SAAS;;;KAIC;EACV;;;;;;;;KASU;EACV;EACA;EACA,SAAS;;;KAIC,0BAA0B,SAAS;KAEnC;EACV;EACA;EACA;EACA,SAAS;EACT;;KAGU;EACV;EACA;EACA;EACA,SAAS;EACT;;;KAIU,yBACR,oCACA;KAEQ;EACV;EACA;EACA;EACA,SAAS;EACT;;KAGU;EACV;EACA;EACA;EACA,SAAS;EACT;;;KAIU,2BACR,sCACA;;;;KAKQ;EACV,QAAQ;EACR,MAAM,eAAe;;;;;;;;KASX;EACV,MAAM;EACN,UAAU;EACV,MAAM,eAAe;;;;;;;;KASX;EACN;EAAc,UAAU;;EAExB;EACA,MAAM;EACN;EACA;;EAEA;;EAEA;;EAEA;;;;;KAKM;EACV;EACA,YAAY;;;;;;;;;KAUF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;EAMA,eAAe;;;;;;;;UC3PA;;;;;;;;;;;;;;;;;;;EAmBf,QAAQ,SAAS,2BAA2B,QAAQ;;;;;;;;;;;;EAapD,KACE,KAAK,eACL,UAAU,wBACT,QAAQ;;;;;;;;;;;;;;;;;EAkBX,IACE,KAAK,eACL,UAAU,cAAc,4BACvB,QAAQ;;;;;;;;;;;EAYX,kBACE,KAAK,eACL,SAAS,kCACR,QAAQ;;;;;;UAOI;;;;EAIf;;;;;;EAOA,KAAK;;;;;;WAOI;;WAGA,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCxB,KACE,MAAM,eAAe,cAAc,MACnC,UAAU,wBACT,QAAQ;;;;;;;;;;;UAYI;;;;;;;;;;;;;;EAcf,KAAK,MAAM,gBAAgB,sBAAsB,QAAQ;;;;;;;;;;;;;;;;;;;EAoBzD,IACE,MAAM,gBACN,SAAS,aACT,sBACC,QAAQ;;;;;;EAOX,mBACE,MAAM,gBACN,SAAS,kCACR,QAAQ;;;;;;;;UASI,yBAAyB;;;;;;;EAOxC,IAAI,MAAM,iBAAiB;;;;;;;;;;;;EAa3B,IACE,MAAM,gBACN,UAAU,oBACV,MAAM,eAAe,cACpB;;;;;;;;;;;;;;;;EAiBH,MAAM,MAAM,iBAAiB;;;;;EAM7B,eAAe;;;;;;;;;UAUA;;;;;;;;;;;;;;;EAef,MACE,MAAM,gBACN,oBACA,SAAS,cACR,QAAQ;;;;;;;EAQX,SAAS,MAAM,iBAAiB;;;;;;;;;;;EAYhC,KACE,MAAM,gBACN,gBACA,MAAM,eAAe,cACpB;;;;;;UAOY;EACf,SAAS,QAAQ,4BAA4B;;;;;;UAO9B;EACf,OAAO,SAAS,2BAA2B,QAAQ;EACnD,IAAI,wBAAwB,QAAQ;EACpC,OAAO,wBAAwB;;;;;;;;EAS/B,cAAc,MAAM,OAAO;;;;;;;UAQZ;EACf,aAAa,aAAa,cAAc;;;;;;;UAQzB;WACN,MAAM;EACf,oBACE,aAAa,cACZ,QAAQ;;;;;;EAMX,sBACE,MAAM,gBACN,sBACC,QAAQ;EACX,OAAO,MAAM,iBAAiB;EAC9B,UAAU,QAAQ"}
|