@powerhousedao/reactor-attachments 6.2.3-dev.7 → 6.2.3-dev.71
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
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { A as InvalidAttachmentRef, C as AttachmentMetadataField, D as AttachmentTransferStage, E as AttachmentTransferError, M as SizeMismatch, N as UploadTooLarge, O as HashMismatch, S as AttachmentAlreadyExists, T as AttachmentPending, _ as createRef, a as RemoteAttachmentUpload, b as parseAttachmentDownloadTarget, c as XhrUploadTransportOptions, d as AttachmentUploadResponse, f as AttachmentUploadTransport, g as ParsedRef, h as SwitchboardTransportConfig, i as RemoteAttachmentUploadFactory, j as ReservationNotFound, k as InvalidAttachmentMetadata, l as createXhrUploadTransport, m as SwitchboardAttachmentTransport, n as createRemoteAttachmentService, o as RemoteReservationStore, p as createFetchUploadTransport, r as RemoteAttachmentStore, s as SwitchboardClientConfig, t as NullAttachmentTransport, u as AttachmentUploadRequest, v as parseRef, w as AttachmentNotFound, x as parseAttachmentUploadTarget, y as AttachmentService } from "./null-attachment-transport-Bs4JpmFx.js";
|
|
2
|
+
import { A as UploadFirstReserveAttachmentOptions, C as AttachmentUploadResult, D as ReserveAttachmentOptions, E as Reservation, O as TransportFetchResult, S as AttachmentTransportConfig, T as HashFirstReserveAttachmentOptions, _ as AttachmentResponse, a as IAttachmentTransport, b as AttachmentStatus, c as IAttachmentUploadFactory, d as AttachmentBackendKind, f as AttachmentDownloadOptions, g as AttachmentMetadata, h as AttachmentHeader, i as IAttachmentStore, k as TransportResponse, l as IReservationStore, m as AttachmentDownloadTargetOptions, n as IAttachmentReader, o as IAttachmentTransportFactory, p as AttachmentDownloadTarget, r as IAttachmentService, s as IAttachmentUpload, t as IAttachmentBackend, u as AttachmentBackendHealth, v as AttachmentSendOptions, w as AttachmentUploadTarget, x as AttachmentTargetHeaders, y as AttachmentStatOptions } from "./interfaces-C4GRlKeB.js";
|
|
3
|
+
import { a as IAttachmentReferenceScanner, c as IAttachmentSchemaCompiler, i as IAttachmentReferenceReader, n as AttachmentReferencePageResult, o as IAttachmentReferenceWriter, s as CompiledAttachmentExtractor, t as AttachmentReferenceInput } from "./types-AagIcjTD.js";
|
|
4
|
+
import { Kysely } from "kysely";
|
|
4
5
|
import { AttachmentHash, AttachmentRef, BaseReadModel, DocumentViewDatabase, IConsistencyTracker, IDocumentModelRegistry, IOperationIndex, IWriteCache } from "@powerhousedao/reactor";
|
|
5
|
-
import {
|
|
6
|
-
|
|
6
|
+
import { DocumentModelModule, OperationWithContext } from "@powerhousedao/shared/document-model";
|
|
7
|
+
//#region src/reserve-metadata.d.ts
|
|
8
|
+
/** The descriptive fields of a reservation, as a caller supplies them. */
|
|
9
|
+
type ReserveMetadata = {
|
|
10
|
+
mimeType: string;
|
|
11
|
+
fileName: string;
|
|
12
|
+
extension?: string | null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Validates reserve metadata with the rules the switchboard reserve route
|
|
16
|
+
* applies.
|
|
17
|
+
*
|
|
18
|
+
* @throws InvalidAttachmentMetadata naming the first field that fails.
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateReserveMetadata(meta: ReserveMetadata): void;
|
|
21
|
+
//#endregion
|
|
7
22
|
//#region src/storage/kysely/types.d.ts
|
|
8
23
|
interface AttachmentTable {
|
|
9
24
|
hash: string;
|
|
@@ -34,7 +49,7 @@ interface AttachmentDatabase {
|
|
|
34
49
|
}
|
|
35
50
|
//#endregion
|
|
36
51
|
//#region src/storage/kysely/attachment-store.d.ts
|
|
37
|
-
declare class KyselyAttachmentStore implements IAttachmentStore {
|
|
52
|
+
export declare class KyselyAttachmentStore implements IAttachmentStore {
|
|
38
53
|
private readonly db;
|
|
39
54
|
private readonly transport;
|
|
40
55
|
private readonly basePath;
|
|
@@ -42,10 +57,11 @@ declare class KyselyAttachmentStore implements IAttachmentStore {
|
|
|
42
57
|
constructor(db: Kysely<AttachmentDatabase>, transport: IAttachmentTransport, basePath: string);
|
|
43
58
|
stat(hash: AttachmentHash): Promise<AttachmentHeader>;
|
|
44
59
|
has(hash: AttachmentHash): Promise<boolean>;
|
|
45
|
-
get(hash: AttachmentHash, signal?: AbortSignal): Promise<AttachmentResponse>;
|
|
60
|
+
get(hash: AttachmentHash, signal?: AbortSignal, documentId?: string): Promise<AttachmentResponse>;
|
|
46
61
|
put(hash: AttachmentHash, metadata: AttachmentMetadata, data: ReadableStream<Uint8Array>): Promise<void>;
|
|
47
62
|
evict(hash: AttachmentHash): Promise<void>;
|
|
48
63
|
storageUsed(): Promise<number>;
|
|
64
|
+
private fetchRemote;
|
|
49
65
|
private findPendingReservation;
|
|
50
66
|
private acquireReader;
|
|
51
67
|
private releaseReader;
|
|
@@ -53,8 +69,8 @@ declare class KyselyAttachmentStore implements IAttachmentStore {
|
|
|
53
69
|
}
|
|
54
70
|
//#endregion
|
|
55
71
|
//#region src/storage/kysely/reservation-store.d.ts
|
|
56
|
-
declare const DEFAULT_RESERVATION_TTL_MS: number;
|
|
57
|
-
declare class KyselyReservationStore implements IReservationStore {
|
|
72
|
+
export declare const DEFAULT_RESERVATION_TTL_MS: number;
|
|
73
|
+
export declare class KyselyReservationStore implements IReservationStore {
|
|
58
74
|
private readonly db;
|
|
59
75
|
private readonly ttlMs;
|
|
60
76
|
constructor(db: Kysely<AttachmentDatabase>, ttlMs?: number);
|
|
@@ -65,16 +81,16 @@ declare class KyselyReservationStore implements IReservationStore {
|
|
|
65
81
|
}
|
|
66
82
|
//#endregion
|
|
67
83
|
//#region src/storage/migrations/migrator.d.ts
|
|
68
|
-
declare const ATTACHMENT_SCHEMA = "attachments";
|
|
84
|
+
export declare const ATTACHMENT_SCHEMA = "attachments";
|
|
69
85
|
interface MigrationResult {
|
|
70
86
|
success: boolean;
|
|
71
87
|
migrationsExecuted: string[];
|
|
72
88
|
error?: Error;
|
|
73
89
|
}
|
|
74
|
-
declare function runAttachmentMigrations(db: Kysely<any>, schema?: string): Promise<MigrationResult>;
|
|
90
|
+
export declare function runAttachmentMigrations(db: Kysely<any>, schema?: string): Promise<MigrationResult>;
|
|
75
91
|
//#endregion
|
|
76
92
|
//#region src/direct/direct-attachment-upload.d.ts
|
|
77
|
-
declare class DirectAttachmentUpload implements IAttachmentUpload {
|
|
93
|
+
export declare class DirectAttachmentUpload implements IAttachmentUpload {
|
|
78
94
|
private readonly reservation;
|
|
79
95
|
private readonly db;
|
|
80
96
|
private readonly basePath;
|
|
@@ -84,11 +100,11 @@ declare class DirectAttachmentUpload implements IAttachmentUpload {
|
|
|
84
100
|
readonly ref: AttachmentRef | null;
|
|
85
101
|
readonly expiresAtUtc: string;
|
|
86
102
|
constructor(reservation: Reservation, db: Kysely<AttachmentDatabase>, basePath: string, reservations: IReservationStore, maxBytes?: number | undefined);
|
|
87
|
-
send(data: ReadableStream<Uint8Array
|
|
103
|
+
send(data: ReadableStream<Uint8Array> | Blob, options?: AttachmentSendOptions): Promise<AttachmentUploadResult>;
|
|
88
104
|
}
|
|
89
105
|
//#endregion
|
|
90
106
|
//#region src/direct/direct-attachment-upload-factory.d.ts
|
|
91
|
-
declare class DirectAttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
107
|
+
export declare class DirectAttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
92
108
|
private readonly db;
|
|
93
109
|
private readonly basePath;
|
|
94
110
|
private readonly reservations;
|
|
@@ -108,7 +124,7 @@ type FilesystemAttachmentBackendConfig = {
|
|
|
108
124
|
* at the server edge, while this adapter validates that a filesystem backend
|
|
109
125
|
* can never accidentally return a direct-provider target.
|
|
110
126
|
*/
|
|
111
|
-
declare class FilesystemAttachmentBackend implements IAttachmentBackend {
|
|
127
|
+
export declare class FilesystemAttachmentBackend implements IAttachmentBackend {
|
|
112
128
|
private readonly store;
|
|
113
129
|
private readonly config;
|
|
114
130
|
readonly kind: "filesystem";
|
|
@@ -124,11 +140,13 @@ type AttachmentBuildResult = {
|
|
|
124
140
|
service: AttachmentService;
|
|
125
141
|
store: KyselyAttachmentStore;
|
|
126
142
|
reservations: KyselyReservationStore;
|
|
127
|
-
uploadFactory: IAttachmentUploadFactory;
|
|
128
|
-
|
|
143
|
+
uploadFactory: IAttachmentUploadFactory;
|
|
144
|
+
/** Selected direct-transfer backend, when startup configured one. */
|
|
145
|
+
backend?: IAttachmentBackend;
|
|
146
|
+
/** Stops the reservation sweep timer, if one was configured via withReservationSweepMs(). */
|
|
129
147
|
destroy: () => void;
|
|
130
148
|
};
|
|
131
|
-
declare class AttachmentBuilder {
|
|
149
|
+
export declare class AttachmentBuilder {
|
|
132
150
|
private readonly db;
|
|
133
151
|
private readonly storagePath;
|
|
134
152
|
private transport;
|
|
@@ -153,98 +171,40 @@ declare class AttachmentBuilder {
|
|
|
153
171
|
build(): Promise<AttachmentBuildResult>;
|
|
154
172
|
}
|
|
155
173
|
//#endregion
|
|
156
|
-
//#region src/reference-index/types.d.ts
|
|
157
|
-
interface CompiledAttachmentExtractor {
|
|
158
|
-
extract(action: Action): AttachmentRef[];
|
|
159
|
-
}
|
|
160
|
-
interface IAttachmentSchemaCompiler {
|
|
161
|
-
forModuleAction(module: DocumentModelModule, actionType: string): CompiledAttachmentExtractor;
|
|
162
|
-
}
|
|
163
|
-
//#endregion
|
|
164
174
|
//#region src/reference-index/attachment-schema-compiler.d.ts
|
|
165
|
-
declare class AttachmentSchemaCompiler implements IAttachmentSchemaCompiler {
|
|
175
|
+
export declare class AttachmentSchemaCompiler implements IAttachmentSchemaCompiler {
|
|
166
176
|
private readonly cache;
|
|
167
177
|
forModuleAction(module: DocumentModelModule, actionType: string): CompiledAttachmentExtractor;
|
|
168
178
|
}
|
|
169
179
|
//#endregion
|
|
170
|
-
//#region src/read-models/attachment-reference/types.d.ts
|
|
171
|
-
interface AttachmentReferenceInput {
|
|
172
|
-
documentId: string;
|
|
173
|
-
ref: AttachmentRef;
|
|
174
|
-
operationId: string;
|
|
175
|
-
branch: string;
|
|
176
|
-
scope: string;
|
|
177
|
-
ordinal: number;
|
|
178
|
-
}
|
|
179
|
-
interface IAttachmentReferenceReader {
|
|
180
|
-
hasReference(documentId: string, ref: AttachmentRef): Promise<boolean>;
|
|
181
|
-
}
|
|
182
|
-
interface IAttachmentReferenceWriter {
|
|
183
|
-
addReferences(references: readonly AttachmentReferenceInput[]): Promise<void>;
|
|
184
|
-
}
|
|
185
|
-
//#endregion
|
|
186
180
|
//#region src/read-models/attachment-reference/index-builder.d.ts
|
|
187
181
|
type AttachmentReferenceIndexBuildResult = {
|
|
188
182
|
store: IAttachmentReferenceReader & IAttachmentReferenceWriter;
|
|
189
183
|
};
|
|
190
|
-
declare class AttachmentReferenceIndexBuilder {
|
|
184
|
+
export declare class AttachmentReferenceIndexBuilder {
|
|
191
185
|
private readonly db;
|
|
192
186
|
constructor(db: Kysely<unknown>);
|
|
193
187
|
build(): Promise<AttachmentReferenceIndexBuildResult>;
|
|
194
188
|
}
|
|
195
189
|
//#endregion
|
|
196
190
|
//#region src/read-models/attachment-reference/attachment-reference-read-model.d.ts
|
|
197
|
-
declare const ATTACHMENT_REFERENCE_READ_MODEL_ID = "attachment-reference-read-model";
|
|
198
|
-
|
|
191
|
+
export declare const ATTACHMENT_REFERENCE_READ_MODEL_ID = "attachment-reference-read-model";
|
|
192
|
+
/**
|
|
193
|
+
* Indexes attachment references in chunks.
|
|
194
|
+
*
|
|
195
|
+
* Each reference row stands on its own and is written insert-or-do-nothing, so
|
|
196
|
+
* a batch that commits in pieces exposes no partial structure, and re-indexing
|
|
197
|
+
* the same range writes nothing new: the catch-up sweep needs no stream suffix.
|
|
198
|
+
*
|
|
199
|
+
* The rows live on another handle, so the purge fence is "skip": a tombstoned
|
|
200
|
+
* id's operations are dropped at commit and its marker deletes its rows.
|
|
201
|
+
*/
|
|
202
|
+
export declare class AttachmentReferenceReadModel extends BaseReadModel {
|
|
199
203
|
private readonly documentModelRegistry;
|
|
200
204
|
private readonly schemaCompiler;
|
|
201
205
|
private readonly referenceWriter;
|
|
202
|
-
private indexingQueue;
|
|
203
|
-
private checkpointTarget;
|
|
204
|
-
/**
|
|
205
|
-
* How far a replay may skip ahead of the cursor: the highest ordinal already
|
|
206
|
-
* pulled from the index while the cursor was parked.
|
|
207
|
-
*
|
|
208
|
-
* NOT a claim that every ordinal below it committed -- the parked ordinal is
|
|
209
|
-
* precisely the one that did not -- so it is a hint, and {@link replayFrom}
|
|
210
|
-
* re-probes the gap before honouring it.
|
|
211
|
-
*/
|
|
212
|
-
private replayedThrough;
|
|
213
|
-
private warnedCheckpoint;
|
|
214
206
|
constructor(db: Kysely<DocumentViewDatabase>, operationIndex: IOperationIndex, writeCache: IWriteCache, consistencyTracker: IConsistencyTracker, documentModelRegistry: IDocumentModelRegistry, schemaCompiler: IAttachmentSchemaCompiler, referenceWriter: IAttachmentReferenceWriter);
|
|
215
|
-
indexOperations(items: OperationWithContext[]): Promise<void>;
|
|
216
|
-
init(): Promise<void>;
|
|
217
|
-
private enqueue;
|
|
218
207
|
protected commitOperations(items: OperationWithContext[]): Promise<void>;
|
|
219
|
-
private indexOperationsInOrdinalOrder;
|
|
220
|
-
/**
|
|
221
|
-
* Writes the cursor parked by indexOperationsInOrdinalOrder instead of the
|
|
222
|
-
* batch maximum, so indexing an operation above a gap never advances past it.
|
|
223
|
-
*/
|
|
224
|
-
protected saveState(trx: Transaction<DocumentViewDatabase>, items: OperationWithContext[]): Promise<void>;
|
|
225
|
-
/** Last ordinal of the contiguous run starting at lastOrdinal + 1. */
|
|
226
|
-
private contiguousEnd;
|
|
227
|
-
/**
|
|
228
|
-
* Opens a replay at the lowest ordinal still worth reading.
|
|
229
|
-
*
|
|
230
|
-
* {@link replayedThrough} is what keeps a permanently held hole -- a
|
|
231
|
-
* rolled-back insert, which never fills -- from re-reading the whole tail on
|
|
232
|
-
* every batch. It cannot be trusted on its own: a hole that fills without
|
|
233
|
-
* being delivered here is visible only in the index, and a mark that is
|
|
234
|
-
* never questioned would hide that operation for the life of the process.
|
|
235
|
-
* That happens whenever another writer commits the gap (a second reactor on
|
|
236
|
-
* the same database), and it leaves the cursor parked below an operation
|
|
237
|
-
* whose references were never written -- `hasReference` then answers false
|
|
238
|
-
* for an attachment that is genuinely referenced.
|
|
239
|
-
*
|
|
240
|
-
* So a parked batch spends one page probing the gap: the first row above the
|
|
241
|
-
* cursor is the missing ordinal itself once it commits. Finding it drops the
|
|
242
|
-
* mark and replays from the cursor; not finding it leaves the mark standing,
|
|
243
|
-
* which is the cheap path and the common one.
|
|
244
|
-
*/
|
|
245
|
-
private replayFrom;
|
|
246
|
-
private loadThroughOrdinal;
|
|
247
|
-
private sortAndDedupe;
|
|
248
208
|
}
|
|
249
209
|
//#endregion
|
|
250
210
|
//#region src/read-models/attachment-reference/storage/types.d.ts
|
|
@@ -263,31 +223,40 @@ interface AttachmentReferenceDatabase {
|
|
|
263
223
|
}
|
|
264
224
|
//#endregion
|
|
265
225
|
//#region src/read-models/attachment-reference/kysely-attachment-reference-store.d.ts
|
|
266
|
-
declare class KyselyAttachmentReferenceStore implements IAttachmentReferenceReader, IAttachmentReferenceWriter {
|
|
226
|
+
export declare class KyselyAttachmentReferenceStore implements IAttachmentReferenceReader, IAttachmentReferenceScanner, IAttachmentReferenceWriter {
|
|
267
227
|
private readonly db;
|
|
268
228
|
constructor(db: Kysely<AttachmentReferenceDatabase>);
|
|
269
229
|
hasReference(documentId: string, ref: AttachmentRef): Promise<boolean>;
|
|
230
|
+
referencingScopes(documentId: string, ref: AttachmentRef): Promise<string[]>;
|
|
231
|
+
/**
|
|
232
|
+
* Keyset paging over the unique `(document_id, attachment_ref)` constraint,
|
|
233
|
+
* rather than OFFSET: a scan that runs while the read model is still
|
|
234
|
+
* indexing must not skip or repeat a row because rows appeared behind the
|
|
235
|
+
* cursor. That is exactly the boot case the replicator's re-scan runs in.
|
|
236
|
+
*/
|
|
237
|
+
listReferences(cursor: string | undefined, limit: number): Promise<AttachmentReferencePageResult>;
|
|
270
238
|
addReferences(references: readonly AttachmentReferenceInput[]): Promise<void>;
|
|
239
|
+
removeDocuments(documentIds: readonly string[]): Promise<void>;
|
|
271
240
|
}
|
|
272
241
|
//#endregion
|
|
273
242
|
//#region src/read-models/attachment-reference/storage/migrations/migrator.d.ts
|
|
274
|
-
declare const ATTACHMENT_REFERENCE_SCHEMA = "attachment_reference_read_model";
|
|
275
|
-
declare const ATTACHMENT_REFERENCE_MIGRATION_TABLE = "kysely_migration_attachment_reference_read_model";
|
|
276
|
-
declare const ATTACHMENT_REFERENCE_MIGRATION_LOCK_TABLE = "kysely_migration_attachment_reference_read_model_lock";
|
|
243
|
+
export declare const ATTACHMENT_REFERENCE_SCHEMA = "attachment_reference_read_model";
|
|
244
|
+
export declare const ATTACHMENT_REFERENCE_MIGRATION_TABLE = "kysely_migration_attachment_reference_read_model";
|
|
245
|
+
export declare const ATTACHMENT_REFERENCE_MIGRATION_LOCK_TABLE = "kysely_migration_attachment_reference_read_model_lock";
|
|
277
246
|
interface AttachmentReferenceMigrationResult {
|
|
278
247
|
success: boolean;
|
|
279
248
|
migrationsExecuted: string[];
|
|
280
249
|
error?: Error;
|
|
281
250
|
}
|
|
282
|
-
declare function runAttachmentReferenceMigrations(db: Kysely<unknown>, schema?: string): Promise<AttachmentReferenceMigrationResult>;
|
|
283
|
-
declare function rollbackAttachmentReferenceMigration(db: Kysely<unknown>, schema?: string): Promise<AttachmentReferenceMigrationResult>;
|
|
284
|
-
declare function getAttachmentReferenceMigrationStatus(db: Kysely<unknown>, schema?: string): Promise<readonly kysely.MigrationInfo[]>;
|
|
251
|
+
export declare function runAttachmentReferenceMigrations(db: Kysely<unknown>, schema?: string): Promise<AttachmentReferenceMigrationResult>;
|
|
252
|
+
export declare function rollbackAttachmentReferenceMigration(db: Kysely<unknown>, schema?: string): Promise<AttachmentReferenceMigrationResult>;
|
|
253
|
+
export declare function getAttachmentReferenceMigrationStatus(db: Kysely<unknown>, schema?: string): Promise<readonly import("kysely").MigrationInfo[]>;
|
|
285
254
|
//#endregion
|
|
286
255
|
//#region src/storage/s3/config.d.ts
|
|
287
|
-
declare const DEFAULT_S3_ATTACHMENT_PREFIX = "attachments";
|
|
288
|
-
declare const DEFAULT_S3_UPLOAD_TTL_SECONDS = 900;
|
|
289
|
-
declare const DEFAULT_S3_DOWNLOAD_TTL_SECONDS = 300;
|
|
290
|
-
declare const MAX_S3_PRESIGN_TTL_SECONDS = 604800;
|
|
256
|
+
export declare const DEFAULT_S3_ATTACHMENT_PREFIX = "attachments";
|
|
257
|
+
export declare const DEFAULT_S3_UPLOAD_TTL_SECONDS = 900;
|
|
258
|
+
export declare const DEFAULT_S3_DOWNLOAD_TTL_SECONDS = 300;
|
|
259
|
+
export declare const MAX_S3_PRESIGN_TTL_SECONDS = 604800;
|
|
291
260
|
type S3AttachmentConfig = {
|
|
292
261
|
endpoint: string;
|
|
293
262
|
region: string;
|
|
@@ -306,12 +275,12 @@ type AttachmentStorageConfig = {
|
|
|
306
275
|
s3: S3AttachmentConfig;
|
|
307
276
|
};
|
|
308
277
|
type Environment = Readonly<Record<string, string | undefined>>;
|
|
309
|
-
declare function normalizeS3AttachmentPrefix(prefix: string): string;
|
|
310
|
-
declare function parseAttachmentStorageConfig(env?: Environment): AttachmentStorageConfig;
|
|
278
|
+
export declare function normalizeS3AttachmentPrefix(prefix: string): string;
|
|
279
|
+
export declare function parseAttachmentStorageConfig(env?: Environment): AttachmentStorageConfig;
|
|
311
280
|
//#endregion
|
|
312
281
|
//#region src/storage/s3/keying.d.ts
|
|
313
|
-
declare function deriveS3AttachmentKey(hash: string, prefix: string): string;
|
|
314
|
-
declare function sha256HexToBase64(hash: string): string;
|
|
282
|
+
export declare function deriveS3AttachmentKey(hash: string, prefix: string): string;
|
|
283
|
+
export declare function sha256HexToBase64(hash: string): string;
|
|
315
284
|
//#endregion
|
|
316
285
|
//#region src/storage/s3/primitives.d.ts
|
|
317
286
|
interface S3CommandClient {
|
|
@@ -323,7 +292,7 @@ type Dependencies = {
|
|
|
323
292
|
presign?: S3Presigner;
|
|
324
293
|
now?: () => Date;
|
|
325
294
|
};
|
|
326
|
-
declare class S3AttachmentPrimitives {
|
|
295
|
+
export declare class S3AttachmentPrimitives {
|
|
327
296
|
readonly config: S3AttachmentConfig;
|
|
328
297
|
readonly client: S3CommandClient;
|
|
329
298
|
readonly presign: S3Presigner;
|
|
@@ -336,7 +305,7 @@ declare class S3AttachmentPrimitives {
|
|
|
336
305
|
createUploadTarget(hash: string, mimeType: string, ttlSeconds?: number): Promise<AttachmentUploadTarget>;
|
|
337
306
|
createDownloadTarget(hash: string, ttlSeconds?: number): Promise<AttachmentDownloadTarget>;
|
|
338
307
|
}
|
|
339
|
-
declare function createS3AttachmentPrimitives(config: S3AttachmentConfig, dependencies?: Dependencies): S3AttachmentPrimitives;
|
|
308
|
+
export declare function createS3AttachmentPrimitives(config: S3AttachmentConfig, dependencies?: Dependencies): S3AttachmentPrimitives;
|
|
340
309
|
//#endregion
|
|
341
310
|
//#region src/storage/s3/backend.d.ts
|
|
342
311
|
type S3AttachmentBackendDependencies = {
|
|
@@ -347,7 +316,7 @@ type S3AttachmentBackendDependencies = {
|
|
|
347
316
|
downloadTtlSeconds?: number;
|
|
348
317
|
};
|
|
349
318
|
/** Server-only S3 capability. Callers complete authorization before download. */
|
|
350
|
-
declare class S3AttachmentBackend implements IAttachmentBackend {
|
|
319
|
+
export declare class S3AttachmentBackend implements IAttachmentBackend {
|
|
351
320
|
private readonly db;
|
|
352
321
|
readonly config: S3AttachmentConfig;
|
|
353
322
|
readonly kind: "s3";
|
|
@@ -361,12 +330,13 @@ declare class S3AttachmentBackend implements IAttachmentBackend {
|
|
|
361
330
|
exists(hash: AttachmentHash): Promise<boolean>;
|
|
362
331
|
health(): Promise<AttachmentBackendHealth>;
|
|
363
332
|
}
|
|
364
|
-
declare function createS3AttachmentBackend(db: Kysely<AttachmentDatabase>, config: S3AttachmentConfig, dependencies?: S3AttachmentBackendDependencies): S3AttachmentBackend;
|
|
333
|
+
export declare function createS3AttachmentBackend(db: Kysely<AttachmentDatabase>, config: S3AttachmentConfig, dependencies?: S3AttachmentBackendDependencies): S3AttachmentBackend;
|
|
365
334
|
//#endregion
|
|
366
335
|
//#region src/storage/s3/upload-factory.d.ts
|
|
367
|
-
declare class S3AttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
336
|
+
export declare class S3AttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
368
337
|
createUpload(reservation: Reservation): IAttachmentUpload;
|
|
369
338
|
}
|
|
370
339
|
//#endregion
|
|
371
|
-
export {
|
|
340
|
+
export { AttachmentAlreadyExists, type AttachmentBackendHealth, type AttachmentBackendKind, type AttachmentBuildResult, type AttachmentDatabase, type AttachmentDownloadOptions, type AttachmentDownloadTarget, type AttachmentDownloadTargetOptions, type AttachmentHeader, type AttachmentMetadata, type AttachmentMetadataField, AttachmentNotFound, AttachmentPending, type AttachmentReferenceIndexBuildResult, type AttachmentReferenceInput, type AttachmentReferenceMigrationResult, type AttachmentResponse, type AttachmentSendOptions, AttachmentService, type AttachmentStatOptions, type AttachmentStatus, type AttachmentStorageConfig, type AttachmentTargetHeaders, AttachmentTransferError, type AttachmentTransferStage, type AttachmentTransportConfig, type AttachmentUploadRequest, type AttachmentUploadResponse, type AttachmentUploadResult, type AttachmentUploadTarget, type AttachmentUploadTransport, type CompiledAttachmentExtractor, type FilesystemAttachmentBackendConfig, type HashFirstReserveAttachmentOptions, HashMismatch, type IAttachmentBackend, type IAttachmentReader, type IAttachmentReferenceReader, type IAttachmentReferenceWriter, type IAttachmentSchemaCompiler, type IAttachmentService, type IAttachmentStore, type IAttachmentTransport, type IAttachmentTransportFactory, type IAttachmentUpload, type IAttachmentUploadFactory, type IReservationStore, InvalidAttachmentMetadata, InvalidAttachmentRef, NullAttachmentTransport, type ParsedRef, RemoteAttachmentStore, RemoteAttachmentUpload, RemoteAttachmentUploadFactory, RemoteReservationStore, type Reservation, ReservationNotFound, type ReserveAttachmentOptions, type ReserveMetadata, type S3AttachmentBackendDependencies, type S3AttachmentConfig, type S3CommandClient, type S3Presigner, SizeMismatch, SwitchboardAttachmentTransport, type SwitchboardClientConfig, type SwitchboardTransportConfig, type TransportFetchResult, type TransportResponse, type UploadFirstReserveAttachmentOptions, UploadTooLarge, type XhrUploadTransportOptions, createFetchUploadTransport, createRef, createRemoteAttachmentService, createXhrUploadTransport, parseAttachmentDownloadTarget, parseAttachmentUploadTarget, parseRef };
|
|
341
|
+
export {};
|
|
372
342
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/storage/kysely/types.ts","../src/storage/kysely/attachment-store.ts","../src/storage/kysely/reservation-store.ts","../src/storage/migrations/migrator.ts","../src/direct/direct-attachment-upload.ts","../src/direct/direct-attachment-upload-factory.ts","../src/direct/filesystem-attachment-backend.ts","../src/attachment-builder.ts","../src/reference-index/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/reserve-metadata.ts","../src/storage/kysely/types.ts","../src/storage/kysely/attachment-store.ts","../src/storage/kysely/reservation-store.ts","../src/storage/migrations/migrator.ts","../src/direct/direct-attachment-upload.ts","../src/direct/direct-attachment-upload-factory.ts","../src/direct/filesystem-attachment-backend.ts","../src/attachment-builder.ts","../src/reference-index/attachment-schema-compiler.ts","../src/read-models/attachment-reference/index-builder.ts","../src/read-models/attachment-reference/attachment-reference-read-model.ts","../src/read-models/attachment-reference/storage/types.ts","../src/read-models/attachment-reference/kysely-attachment-reference-store.ts","../src/read-models/attachment-reference/storage/migrations/migrator.ts","../src/storage/s3/config.ts","../src/storage/s3/keying.ts","../src/storage/s3/primitives.ts","../src/storage/s3/backend.ts","../src/storage/s3/upload-factory.ts"],"mappings":";;;;;;;;KAeY;EACV;EACA;EACA;;;;;;;;wBASc,wBAAwB,MAAM;;;UCzB7B;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,YAAY;EACZ,wBAAwB;;;;qBC4Cb,iCAAiC;mBAIzB;mBACA;mBACA;mBALF;EAEjB,YACmB,IAAI,OAAO,qBACX,WAAW,sBACX;EAGb,KAAK,MAAM,iBAAiB,QAAQ;EAgCpC,IAAI,MAAM,iBAAiB;EAU3B,IACJ,MAAM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