@powerhousedao/reactor-attachments 6.2.3-dev.23 → 6.2.3-dev.25
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 +51 -36
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -2
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +40 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -8
- package/dist/index.js.map +1 -1
- package/dist/{null-attachment-transport-CMrO_ZKA.d.ts → null-attachment-transport-Bk3oBzHW.d.ts} +4 -3
- package/dist/null-attachment-transport-Bk3oBzHW.d.ts.map +1 -0
- package/dist/{null-attachment-transport-CrsUafCi.js → null-attachment-transport-CRvB9Cnv.js} +7 -2
- package/dist/{null-attachment-transport-CrsUafCi.js.map → null-attachment-transport-CRvB9Cnv.js.map} +1 -1
- package/package.json +5 -5
- package/dist/null-attachment-transport-CMrO_ZKA.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { $ as AttachmentPending, A as IReservationStore, B as AttachmentStatus, C as IAttachmentReader, D as IAttachmentTransportFactory, E as IAttachmentTransport, G as HashFirstReserveAttachmentOptions, H as AttachmentTransportConfig, I as AttachmentHeader, J as TransportFetchResult, K as Reservation, L as AttachmentMetadata, M as AttachmentBackendKind, N as AttachmentDownloadOptions, O as IAttachmentUpload, P as AttachmentDownloadTarget, Q as AttachmentNotFound, R as AttachmentResponse, S as IAttachmentBackend, T as IAttachmentStore, U as AttachmentUploadResult, V as AttachmentTargetHeaders, W as AttachmentUploadTarget, X as UploadFirstReserveAttachmentOptions, Y as TransportResponse, Z as AttachmentAlreadyExists, _ as createRef, a as RemoteAttachmentUpload, at as SizeMismatch, b as parseAttachmentDownloadTarget, c as XhrUploadTransportOptions, d as AttachmentUploadResponse, et as AttachmentTransferError, f as AttachmentUploadTransport, g as ParsedRef, h as SwitchboardTransportConfig, i as RemoteAttachmentUploadFactory, it as ReservationNotFound, j as AttachmentBackendHealth, k as IAttachmentUploadFactory, l as createXhrUploadTransport, m as SwitchboardAttachmentTransport, n as createRemoteAttachmentService, nt as HashMismatch, o as RemoteReservationStore, ot as UploadTooLarge, p as createFetchUploadTransport, q as ReserveAttachmentOptions, r as RemoteAttachmentStore, rt as InvalidAttachmentRef, s as SwitchboardClientConfig, t as NullAttachmentTransport, tt as AttachmentTransferStage, u as AttachmentUploadRequest, v as parseRef, w as IAttachmentService, x as parseAttachmentUploadTarget, y as AttachmentService, z as AttachmentSendOptions } from "./null-attachment-transport-
|
|
2
|
-
import * as kysely from "kysely";
|
|
1
|
+
import { $ as AttachmentPending, A as IReservationStore, B as AttachmentStatus, C as IAttachmentReader, D as IAttachmentTransportFactory, E as IAttachmentTransport, G as HashFirstReserveAttachmentOptions, H as AttachmentTransportConfig, I as AttachmentHeader, J as TransportFetchResult, K as Reservation, L as AttachmentMetadata, M as AttachmentBackendKind, N as AttachmentDownloadOptions, O as IAttachmentUpload, P as AttachmentDownloadTarget, Q as AttachmentNotFound, R as AttachmentResponse, S as IAttachmentBackend, T as IAttachmentStore, U as AttachmentUploadResult, V as AttachmentTargetHeaders, W as AttachmentUploadTarget, X as UploadFirstReserveAttachmentOptions, Y as TransportResponse, Z as AttachmentAlreadyExists, _ as createRef, a as RemoteAttachmentUpload, at as SizeMismatch, b as parseAttachmentDownloadTarget, c as XhrUploadTransportOptions, d as AttachmentUploadResponse, et as AttachmentTransferError, f as AttachmentUploadTransport, g as ParsedRef, h as SwitchboardTransportConfig, i as RemoteAttachmentUploadFactory, it as ReservationNotFound, j as AttachmentBackendHealth, k as IAttachmentUploadFactory, l as createXhrUploadTransport, m as SwitchboardAttachmentTransport, n as createRemoteAttachmentService, nt as HashMismatch, o as RemoteReservationStore, ot as UploadTooLarge, p as createFetchUploadTransport, q as ReserveAttachmentOptions, r as RemoteAttachmentStore, rt as InvalidAttachmentRef, s as SwitchboardClientConfig, t as NullAttachmentTransport, tt as AttachmentTransferStage, u as AttachmentUploadRequest, v as parseRef, w as IAttachmentService, x as parseAttachmentUploadTarget, y as AttachmentService, z as AttachmentSendOptions } from "./null-attachment-transport-Bk3oBzHW.js";
|
|
3
2
|
import { Kysely, Transaction } from "kysely";
|
|
4
3
|
import { AttachmentHash, AttachmentRef, BaseReadModel, DocumentViewDatabase, IConsistencyTracker, IDocumentModelRegistry, IOperationIndex, IWriteCache } from "@powerhousedao/reactor";
|
|
5
4
|
import { Action, DocumentModelModule, OperationWithContext } from "@powerhousedao/shared/document-model";
|
|
6
|
-
|
|
7
5
|
//#region src/storage/kysely/types.d.ts
|
|
8
6
|
interface AttachmentTable {
|
|
9
7
|
hash: string;
|
|
@@ -34,7 +32,7 @@ interface AttachmentDatabase {
|
|
|
34
32
|
}
|
|
35
33
|
//#endregion
|
|
36
34
|
//#region src/storage/kysely/attachment-store.d.ts
|
|
37
|
-
declare class KyselyAttachmentStore implements IAttachmentStore {
|
|
35
|
+
export declare class KyselyAttachmentStore implements IAttachmentStore {
|
|
38
36
|
private readonly db;
|
|
39
37
|
private readonly transport;
|
|
40
38
|
private readonly basePath;
|
|
@@ -53,8 +51,8 @@ declare class KyselyAttachmentStore implements IAttachmentStore {
|
|
|
53
51
|
}
|
|
54
52
|
//#endregion
|
|
55
53
|
//#region src/storage/kysely/reservation-store.d.ts
|
|
56
|
-
declare const DEFAULT_RESERVATION_TTL_MS: number;
|
|
57
|
-
declare class KyselyReservationStore implements IReservationStore {
|
|
54
|
+
export declare const DEFAULT_RESERVATION_TTL_MS: number;
|
|
55
|
+
export declare class KyselyReservationStore implements IReservationStore {
|
|
58
56
|
private readonly db;
|
|
59
57
|
private readonly ttlMs;
|
|
60
58
|
constructor(db: Kysely<AttachmentDatabase>, ttlMs?: number);
|
|
@@ -65,16 +63,16 @@ declare class KyselyReservationStore implements IReservationStore {
|
|
|
65
63
|
}
|
|
66
64
|
//#endregion
|
|
67
65
|
//#region src/storage/migrations/migrator.d.ts
|
|
68
|
-
declare const ATTACHMENT_SCHEMA = "attachments";
|
|
66
|
+
export declare const ATTACHMENT_SCHEMA = "attachments";
|
|
69
67
|
interface MigrationResult {
|
|
70
68
|
success: boolean;
|
|
71
69
|
migrationsExecuted: string[];
|
|
72
70
|
error?: Error;
|
|
73
71
|
}
|
|
74
|
-
declare function runAttachmentMigrations(db: Kysely<any>, schema?: string): Promise<MigrationResult>;
|
|
72
|
+
export declare function runAttachmentMigrations(db: Kysely<any>, schema?: string): Promise<MigrationResult>;
|
|
75
73
|
//#endregion
|
|
76
74
|
//#region src/direct/direct-attachment-upload.d.ts
|
|
77
|
-
declare class DirectAttachmentUpload implements IAttachmentUpload {
|
|
75
|
+
export declare class DirectAttachmentUpload implements IAttachmentUpload {
|
|
78
76
|
private readonly reservation;
|
|
79
77
|
private readonly db;
|
|
80
78
|
private readonly basePath;
|
|
@@ -88,7 +86,7 @@ declare class DirectAttachmentUpload implements IAttachmentUpload {
|
|
|
88
86
|
}
|
|
89
87
|
//#endregion
|
|
90
88
|
//#region src/direct/direct-attachment-upload-factory.d.ts
|
|
91
|
-
declare class DirectAttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
89
|
+
export declare class DirectAttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
92
90
|
private readonly db;
|
|
93
91
|
private readonly basePath;
|
|
94
92
|
private readonly reservations;
|
|
@@ -108,7 +106,7 @@ type FilesystemAttachmentBackendConfig = {
|
|
|
108
106
|
* at the server edge, while this adapter validates that a filesystem backend
|
|
109
107
|
* can never accidentally return a direct-provider target.
|
|
110
108
|
*/
|
|
111
|
-
declare class FilesystemAttachmentBackend implements IAttachmentBackend {
|
|
109
|
+
export declare class FilesystemAttachmentBackend implements IAttachmentBackend {
|
|
112
110
|
private readonly store;
|
|
113
111
|
private readonly config;
|
|
114
112
|
readonly kind: "filesystem";
|
|
@@ -124,11 +122,13 @@ type AttachmentBuildResult = {
|
|
|
124
122
|
service: AttachmentService;
|
|
125
123
|
store: KyselyAttachmentStore;
|
|
126
124
|
reservations: KyselyReservationStore;
|
|
127
|
-
uploadFactory: IAttachmentUploadFactory;
|
|
128
|
-
|
|
125
|
+
uploadFactory: IAttachmentUploadFactory;
|
|
126
|
+
/** Selected direct-transfer backend, when startup configured one. */
|
|
127
|
+
backend?: IAttachmentBackend;
|
|
128
|
+
/** Stops the reservation sweep timer, if one was configured via withReservationSweepMs(). */
|
|
129
129
|
destroy: () => void;
|
|
130
130
|
};
|
|
131
|
-
declare class AttachmentBuilder {
|
|
131
|
+
export declare class AttachmentBuilder {
|
|
132
132
|
private readonly db;
|
|
133
133
|
private readonly storagePath;
|
|
134
134
|
private transport;
|
|
@@ -162,7 +162,7 @@ interface IAttachmentSchemaCompiler {
|
|
|
162
162
|
}
|
|
163
163
|
//#endregion
|
|
164
164
|
//#region src/reference-index/attachment-schema-compiler.d.ts
|
|
165
|
-
declare class AttachmentSchemaCompiler implements IAttachmentSchemaCompiler {
|
|
165
|
+
export declare class AttachmentSchemaCompiler implements IAttachmentSchemaCompiler {
|
|
166
166
|
private readonly cache;
|
|
167
167
|
forModuleAction(module: DocumentModelModule, actionType: string): CompiledAttachmentExtractor;
|
|
168
168
|
}
|
|
@@ -187,14 +187,14 @@ interface IAttachmentReferenceWriter {
|
|
|
187
187
|
type AttachmentReferenceIndexBuildResult = {
|
|
188
188
|
store: IAttachmentReferenceReader & IAttachmentReferenceWriter;
|
|
189
189
|
};
|
|
190
|
-
declare class AttachmentReferenceIndexBuilder {
|
|
190
|
+
export declare class AttachmentReferenceIndexBuilder {
|
|
191
191
|
private readonly db;
|
|
192
192
|
constructor(db: Kysely<unknown>);
|
|
193
193
|
build(): Promise<AttachmentReferenceIndexBuildResult>;
|
|
194
194
|
}
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region src/read-models/attachment-reference/attachment-reference-read-model.d.ts
|
|
197
|
-
declare const ATTACHMENT_REFERENCE_READ_MODEL_ID = "attachment-reference-read-model";
|
|
197
|
+
export declare const ATTACHMENT_REFERENCE_READ_MODEL_ID = "attachment-reference-read-model";
|
|
198
198
|
/**
|
|
199
199
|
* Indexes attachment references in chunks.
|
|
200
200
|
*
|
|
@@ -204,7 +204,7 @@ declare const ATTACHMENT_REFERENCE_READ_MODEL_ID = "attachment-reference-read-mo
|
|
|
204
204
|
* new. Batches here are the largest in the system, which is what chunking is
|
|
205
205
|
* for.
|
|
206
206
|
*/
|
|
207
|
-
declare class AttachmentReferenceReadModel extends BaseReadModel {
|
|
207
|
+
export declare class AttachmentReferenceReadModel extends BaseReadModel {
|
|
208
208
|
private readonly documentModelRegistry;
|
|
209
209
|
private readonly schemaCompiler;
|
|
210
210
|
private readonly referenceWriter;
|
|
@@ -272,7 +272,7 @@ interface AttachmentReferenceDatabase {
|
|
|
272
272
|
}
|
|
273
273
|
//#endregion
|
|
274
274
|
//#region src/read-models/attachment-reference/kysely-attachment-reference-store.d.ts
|
|
275
|
-
declare class KyselyAttachmentReferenceStore implements IAttachmentReferenceReader, IAttachmentReferenceWriter {
|
|
275
|
+
export declare class KyselyAttachmentReferenceStore implements IAttachmentReferenceReader, IAttachmentReferenceWriter {
|
|
276
276
|
private readonly db;
|
|
277
277
|
constructor(db: Kysely<AttachmentReferenceDatabase>);
|
|
278
278
|
hasReference(documentId: string, ref: AttachmentRef): Promise<boolean>;
|
|
@@ -280,23 +280,23 @@ declare class KyselyAttachmentReferenceStore implements IAttachmentReferenceRead
|
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/read-models/attachment-reference/storage/migrations/migrator.d.ts
|
|
283
|
-
declare const ATTACHMENT_REFERENCE_SCHEMA = "attachment_reference_read_model";
|
|
284
|
-
declare const ATTACHMENT_REFERENCE_MIGRATION_TABLE = "kysely_migration_attachment_reference_read_model";
|
|
285
|
-
declare const ATTACHMENT_REFERENCE_MIGRATION_LOCK_TABLE = "kysely_migration_attachment_reference_read_model_lock";
|
|
283
|
+
export declare const ATTACHMENT_REFERENCE_SCHEMA = "attachment_reference_read_model";
|
|
284
|
+
export declare const ATTACHMENT_REFERENCE_MIGRATION_TABLE = "kysely_migration_attachment_reference_read_model";
|
|
285
|
+
export declare const ATTACHMENT_REFERENCE_MIGRATION_LOCK_TABLE = "kysely_migration_attachment_reference_read_model_lock";
|
|
286
286
|
interface AttachmentReferenceMigrationResult {
|
|
287
287
|
success: boolean;
|
|
288
288
|
migrationsExecuted: string[];
|
|
289
289
|
error?: Error;
|
|
290
290
|
}
|
|
291
|
-
declare function runAttachmentReferenceMigrations(db: Kysely<unknown>, schema?: string): Promise<AttachmentReferenceMigrationResult>;
|
|
292
|
-
declare function rollbackAttachmentReferenceMigration(db: Kysely<unknown>, schema?: string): Promise<AttachmentReferenceMigrationResult>;
|
|
293
|
-
declare function getAttachmentReferenceMigrationStatus(db: Kysely<unknown>, schema?: string): Promise<readonly kysely.MigrationInfo[]>;
|
|
291
|
+
export declare function runAttachmentReferenceMigrations(db: Kysely<unknown>, schema?: string): Promise<AttachmentReferenceMigrationResult>;
|
|
292
|
+
export declare function rollbackAttachmentReferenceMigration(db: Kysely<unknown>, schema?: string): Promise<AttachmentReferenceMigrationResult>;
|
|
293
|
+
export declare function getAttachmentReferenceMigrationStatus(db: Kysely<unknown>, schema?: string): Promise<readonly import("kysely").MigrationInfo[]>;
|
|
294
294
|
//#endregion
|
|
295
295
|
//#region src/storage/s3/config.d.ts
|
|
296
|
-
declare const DEFAULT_S3_ATTACHMENT_PREFIX = "attachments";
|
|
297
|
-
declare const DEFAULT_S3_UPLOAD_TTL_SECONDS = 900;
|
|
298
|
-
declare const DEFAULT_S3_DOWNLOAD_TTL_SECONDS = 300;
|
|
299
|
-
declare const MAX_S3_PRESIGN_TTL_SECONDS = 604800;
|
|
296
|
+
export declare const DEFAULT_S3_ATTACHMENT_PREFIX = "attachments";
|
|
297
|
+
export declare const DEFAULT_S3_UPLOAD_TTL_SECONDS = 900;
|
|
298
|
+
export declare const DEFAULT_S3_DOWNLOAD_TTL_SECONDS = 300;
|
|
299
|
+
export declare const MAX_S3_PRESIGN_TTL_SECONDS = 604800;
|
|
300
300
|
type S3AttachmentConfig = {
|
|
301
301
|
endpoint: string;
|
|
302
302
|
region: string;
|
|
@@ -315,12 +315,12 @@ type AttachmentStorageConfig = {
|
|
|
315
315
|
s3: S3AttachmentConfig;
|
|
316
316
|
};
|
|
317
317
|
type Environment = Readonly<Record<string, string | undefined>>;
|
|
318
|
-
declare function normalizeS3AttachmentPrefix(prefix: string): string;
|
|
319
|
-
declare function parseAttachmentStorageConfig(env?: Environment): AttachmentStorageConfig;
|
|
318
|
+
export declare function normalizeS3AttachmentPrefix(prefix: string): string;
|
|
319
|
+
export declare function parseAttachmentStorageConfig(env?: Environment): AttachmentStorageConfig;
|
|
320
320
|
//#endregion
|
|
321
321
|
//#region src/storage/s3/keying.d.ts
|
|
322
|
-
declare function deriveS3AttachmentKey(hash: string, prefix: string): string;
|
|
323
|
-
declare function sha256HexToBase64(hash: string): string;
|
|
322
|
+
export declare function deriveS3AttachmentKey(hash: string, prefix: string): string;
|
|
323
|
+
export declare function sha256HexToBase64(hash: string): string;
|
|
324
324
|
//#endregion
|
|
325
325
|
//#region src/storage/s3/primitives.d.ts
|
|
326
326
|
interface S3CommandClient {
|
|
@@ -332,7 +332,7 @@ type Dependencies = {
|
|
|
332
332
|
presign?: S3Presigner;
|
|
333
333
|
now?: () => Date;
|
|
334
334
|
};
|
|
335
|
-
declare class S3AttachmentPrimitives {
|
|
335
|
+
export declare class S3AttachmentPrimitives {
|
|
336
336
|
readonly config: S3AttachmentConfig;
|
|
337
337
|
readonly client: S3CommandClient;
|
|
338
338
|
readonly presign: S3Presigner;
|
|
@@ -345,7 +345,7 @@ declare class S3AttachmentPrimitives {
|
|
|
345
345
|
createUploadTarget(hash: string, mimeType: string, ttlSeconds?: number): Promise<AttachmentUploadTarget>;
|
|
346
346
|
createDownloadTarget(hash: string, ttlSeconds?: number): Promise<AttachmentDownloadTarget>;
|
|
347
347
|
}
|
|
348
|
-
declare function createS3AttachmentPrimitives(config: S3AttachmentConfig, dependencies?: Dependencies): S3AttachmentPrimitives;
|
|
348
|
+
export declare function createS3AttachmentPrimitives(config: S3AttachmentConfig, dependencies?: Dependencies): S3AttachmentPrimitives;
|
|
349
349
|
//#endregion
|
|
350
350
|
//#region src/storage/s3/backend.d.ts
|
|
351
351
|
type S3AttachmentBackendDependencies = {
|
|
@@ -356,7 +356,7 @@ type S3AttachmentBackendDependencies = {
|
|
|
356
356
|
downloadTtlSeconds?: number;
|
|
357
357
|
};
|
|
358
358
|
/** Server-only S3 capability. Callers complete authorization before download. */
|
|
359
|
-
declare class S3AttachmentBackend implements IAttachmentBackend {
|
|
359
|
+
export declare class S3AttachmentBackend implements IAttachmentBackend {
|
|
360
360
|
private readonly db;
|
|
361
361
|
readonly config: S3AttachmentConfig;
|
|
362
362
|
readonly kind: "s3";
|
|
@@ -370,12 +370,13 @@ declare class S3AttachmentBackend implements IAttachmentBackend {
|
|
|
370
370
|
exists(hash: AttachmentHash): Promise<boolean>;
|
|
371
371
|
health(): Promise<AttachmentBackendHealth>;
|
|
372
372
|
}
|
|
373
|
-
declare function createS3AttachmentBackend(db: Kysely<AttachmentDatabase>, config: S3AttachmentConfig, dependencies?: S3AttachmentBackendDependencies): S3AttachmentBackend;
|
|
373
|
+
export declare function createS3AttachmentBackend(db: Kysely<AttachmentDatabase>, config: S3AttachmentConfig, dependencies?: S3AttachmentBackendDependencies): S3AttachmentBackend;
|
|
374
374
|
//#endregion
|
|
375
375
|
//#region src/storage/s3/upload-factory.d.ts
|
|
376
|
-
declare class S3AttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
376
|
+
export declare class S3AttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
377
377
|
createUpload(reservation: Reservation): IAttachmentUpload;
|
|
378
378
|
}
|
|
379
379
|
//#endregion
|
|
380
|
-
export {
|
|
380
|
+
export { AttachmentAlreadyExists, type AttachmentBackendHealth, type AttachmentBackendKind, type AttachmentBuildResult, type AttachmentDatabase, type AttachmentDownloadOptions, type AttachmentDownloadTarget, type AttachmentHeader, type AttachmentMetadata, AttachmentNotFound, AttachmentPending, type AttachmentReferenceIndexBuildResult, type AttachmentReferenceInput, type AttachmentReferenceMigrationResult, type AttachmentResponse, type AttachmentSendOptions, AttachmentService, 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, InvalidAttachmentRef, NullAttachmentTransport, type ParsedRef, RemoteAttachmentStore, RemoteAttachmentUpload, RemoteAttachmentUploadFactory, RemoteReservationStore, type Reservation, ReservationNotFound, type ReserveAttachmentOptions, 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 };
|
|
381
|
+
export {};
|
|
381
382
|
//# 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/types.ts","../src/reference-index/attachment-schema-compiler.ts","../src/read-models/attachment-reference/types.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":"
|
|
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/types.ts","../src/reference-index/attachment-schema-compiler.ts","../src/read-models/attachment-reference/types.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":";;;;;UAEiB;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;EAU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AAI;;KAEjB,cAAc,SAAS;wBA4EZ,4BAA4B;wBA2B5B,6BACd,MAAK,cACJ;;;wBClHa,sBAAsB,cAAc;wBAuBpC,kBAAkB;;;UCrBjB;EACf,KAAK,kBAAkB;;KAGb,eACV,gBACA,iBACA,6BACG;KAEA;EACH,SAAS;EACT,UAAU;EACV,YAAY;;qBASD;WAMA,QAAQ;WALV,QAAQ;WACR,SAAS;WACT,WAAW;EAEpB,YACW,QAAQ,oBACjB,eAAc;EAiBhB,uBAAuB;EAOvB,sBAAsB,cAAc;EAkBpC,sBAAsB;EAOtB,WAAW,eAAe;EAIpB,mBACJ,cACA,kBACA,sBACC,QAAQ;EAqBL,qBACJ,cACA,sBACC,QAAQ;;wBAkBG,6BACd,QAAQ,oBACR,eAAc,eACb;;;KClHS;EACV,SAAS;EACT,UAAU;EACV,YAAY;EACZ;EACA;;;qBAkCW,+BAA+B;mBAQvB;WACR,QAAQ;WARV;mBACQ;mBACA;mBACA;mBACA;EAEjB,YACmB,IAAI,OAAO,qBACnB,QAAQ,oBACjB,eAAc;EAUV,oBACJ,aAAa,cACZ,QAAQ;EAqDL,sBACJ,MAAM,gBACN,sBACC,QAAQ;EAWL,OAAO,MAAM,iBAAiB;EAoB9B,UAAU,QAAQ;;wBAaV,0BACd,IAAI,OAAO,qBACX,QAAQ,oBACR,eAAc,kCACb;;;qBC7JU,qCAAqC;EAChD,aAAa,aAAa,cAAc"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as UploadTooLarge, S as SizeMismatch, _ as AttachmentPending, a as RemoteAttachmentUpload, b as InvalidAttachmentRef, c as createFetchUploadTransport, d as createRef, f as parseRef, g as AttachmentNotFound, h as AttachmentAlreadyExists, i as RemoteAttachmentUploadFactory, l as SwitchboardAttachmentTransport, m as parseAttachmentUploadTarget, n as createRemoteAttachmentService, o as RemoteReservationStore, p as parseAttachmentDownloadTarget, r as RemoteAttachmentStore, s as createXhrUploadTransport, t as NullAttachmentTransport, u as AttachmentService, v as AttachmentTransferError, x as ReservationNotFound, y as HashMismatch } from "./null-attachment-transport-
|
|
1
|
+
import { C as UploadTooLarge, S as SizeMismatch, _ as AttachmentPending, a as RemoteAttachmentUpload, b as InvalidAttachmentRef, c as createFetchUploadTransport, d as createRef, f as parseRef, g as AttachmentNotFound, h as AttachmentAlreadyExists, i as RemoteAttachmentUploadFactory, l as SwitchboardAttachmentTransport, m as parseAttachmentUploadTarget, n as createRemoteAttachmentService, o as RemoteReservationStore, p as parseAttachmentDownloadTarget, r as RemoteAttachmentStore, s as createXhrUploadTransport, t as NullAttachmentTransport, u as AttachmentService, v as AttachmentTransferError, x as ReservationNotFound, y as HashMismatch } from "./null-attachment-transport-CRvB9Cnv.js";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { Migrator, sql } from "kysely";
|
|
4
4
|
import { mkdir, rename, rm } from "node:fs/promises";
|
|
@@ -262,6 +262,9 @@ function wrapStreamWithCleanup(source, cleanup) {
|
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
264
|
var KyselyAttachmentStore = class {
|
|
265
|
+
db;
|
|
266
|
+
transport;
|
|
267
|
+
basePath;
|
|
265
268
|
activeReaders = /* @__PURE__ */ new Map();
|
|
266
269
|
constructor(db, transport, basePath) {
|
|
267
270
|
this.db = db;
|
|
@@ -398,7 +401,7 @@ var KyselyAttachmentStore = class {
|
|
|
398
401
|
};
|
|
399
402
|
//#endregion
|
|
400
403
|
//#region src/storage/kysely/reservation-store.ts
|
|
401
|
-
const DEFAULT_RESERVATION_TTL_MS =
|
|
404
|
+
const DEFAULT_RESERVATION_TTL_MS = 864e5;
|
|
402
405
|
function rowToReservation(row) {
|
|
403
406
|
return {
|
|
404
407
|
reservationId: row.reservation_id,
|
|
@@ -412,6 +415,7 @@ function rowToReservation(row) {
|
|
|
412
415
|
};
|
|
413
416
|
}
|
|
414
417
|
var KyselyReservationStore = class {
|
|
418
|
+
db;
|
|
415
419
|
ttlMs;
|
|
416
420
|
constructor(db, ttlMs = DEFAULT_RESERVATION_TTL_MS) {
|
|
417
421
|
this.db = db;
|
|
@@ -601,6 +605,11 @@ function rowToHeader(row) {
|
|
|
601
605
|
};
|
|
602
606
|
}
|
|
603
607
|
var DirectAttachmentUpload = class {
|
|
608
|
+
reservation;
|
|
609
|
+
db;
|
|
610
|
+
basePath;
|
|
611
|
+
reservations;
|
|
612
|
+
maxBytes;
|
|
604
613
|
reservationId;
|
|
605
614
|
ref;
|
|
606
615
|
expiresAtUtc;
|
|
@@ -670,6 +679,10 @@ var DirectAttachmentUpload = class {
|
|
|
670
679
|
//#endregion
|
|
671
680
|
//#region src/direct/direct-attachment-upload-factory.ts
|
|
672
681
|
var DirectAttachmentUploadFactory = class {
|
|
682
|
+
db;
|
|
683
|
+
basePath;
|
|
684
|
+
reservations;
|
|
685
|
+
maxBytes;
|
|
673
686
|
constructor(db, basePath, reservations, maxBytes) {
|
|
674
687
|
this.db = db;
|
|
675
688
|
this.basePath = basePath;
|
|
@@ -688,6 +701,8 @@ var DirectAttachmentUploadFactory = class {
|
|
|
688
701
|
* can never accidentally return a direct-provider target.
|
|
689
702
|
*/
|
|
690
703
|
var FilesystemAttachmentBackend = class {
|
|
704
|
+
store;
|
|
705
|
+
config;
|
|
691
706
|
kind = "filesystem";
|
|
692
707
|
constructor(store, config) {
|
|
693
708
|
this.store = store;
|
|
@@ -739,6 +754,8 @@ var S3AttachmentUploadFactory = class {
|
|
|
739
754
|
//#endregion
|
|
740
755
|
//#region src/attachment-builder.ts
|
|
741
756
|
var AttachmentBuilder = class {
|
|
757
|
+
db;
|
|
758
|
+
storagePath;
|
|
742
759
|
transport = new NullAttachmentTransport();
|
|
743
760
|
customUploadFactory;
|
|
744
761
|
maxUploadBytes;
|
|
@@ -811,7 +828,7 @@ var AttachmentBuilder = class {
|
|
|
811
828
|
//#endregion
|
|
812
829
|
//#region src/reference-index/attachment-schema-compiler.ts
|
|
813
830
|
const ATTACHMENT_REF_TYPE = "AttachmentRef";
|
|
814
|
-
const CODEGEN_SCALAR_NAMES = new Set([
|
|
831
|
+
const CODEGEN_SCALAR_NAMES = /* @__PURE__ */ new Set([
|
|
815
832
|
"Unknown",
|
|
816
833
|
"DateTime",
|
|
817
834
|
"Address",
|
|
@@ -859,11 +876,12 @@ function buildEffectiveSchema(specification, context) {
|
|
|
859
876
|
const stateSchemas = Object.values(specification.state).map((state) => state.schema);
|
|
860
877
|
const operationSchemas = specification.modules.flatMap((moduleSpecification) => moduleSpecification.operations.flatMap((operation) => operation.schema === null ? [] : [operation.schema]));
|
|
861
878
|
try {
|
|
862
|
-
|
|
879
|
+
const document = parse([
|
|
863
880
|
...scalarSchemas,
|
|
864
881
|
...stateSchemas,
|
|
865
882
|
...operationSchemas
|
|
866
|
-
].filter(Boolean).join("\n\n"))
|
|
883
|
+
].filter(Boolean).join("\n\n"));
|
|
884
|
+
return buildASTSchema(dedupeTypeDefinitions(document));
|
|
867
885
|
} catch {
|
|
868
886
|
throw compilationError(context, "the effective GraphQL schema is invalid");
|
|
869
887
|
}
|
|
@@ -1001,6 +1019,8 @@ function extractValue(plan, value, path, context, refs, seenRefs, activeObjects)
|
|
|
1001
1019
|
}
|
|
1002
1020
|
}
|
|
1003
1021
|
var SchemaCompiledAttachmentExtractor = class {
|
|
1022
|
+
context;
|
|
1023
|
+
rootPlan;
|
|
1004
1024
|
constructor(context, rootPlan) {
|
|
1005
1025
|
this.context = context;
|
|
1006
1026
|
this.rootPlan = rootPlan;
|
|
@@ -1063,6 +1083,7 @@ var AttachmentSchemaCompiler = class {
|
|
|
1063
1083
|
//#endregion
|
|
1064
1084
|
//#region src/read-models/attachment-reference/kysely-attachment-reference-store.ts
|
|
1065
1085
|
var KyselyAttachmentReferenceStore = class {
|
|
1086
|
+
db;
|
|
1066
1087
|
constructor(db) {
|
|
1067
1088
|
this.db = db;
|
|
1068
1089
|
}
|
|
@@ -1160,6 +1181,7 @@ async function getAttachmentReferenceMigrationStatus(db, schema = ATTACHMENT_REF
|
|
|
1160
1181
|
//#endregion
|
|
1161
1182
|
//#region src/read-models/attachment-reference/index-builder.ts
|
|
1162
1183
|
var AttachmentReferenceIndexBuilder = class {
|
|
1184
|
+
db;
|
|
1163
1185
|
constructor(db) {
|
|
1164
1186
|
this.db = db;
|
|
1165
1187
|
}
|
|
@@ -1182,6 +1204,9 @@ const ATTACHMENT_REFERENCE_READ_MODEL_ID = "attachment-reference-read-model";
|
|
|
1182
1204
|
* for.
|
|
1183
1205
|
*/
|
|
1184
1206
|
var AttachmentReferenceReadModel = class extends BaseReadModel {
|
|
1207
|
+
documentModelRegistry;
|
|
1208
|
+
schemaCompiler;
|
|
1209
|
+
referenceWriter;
|
|
1185
1210
|
indexingQueue = Promise.resolve();
|
|
1186
1211
|
checkpointTarget;
|
|
1187
1212
|
/**
|
|
@@ -1351,7 +1376,7 @@ function required(env, name) {
|
|
|
1351
1376
|
if (value.trim() !== value) throw new Error(`${name} must not have leading or trailing whitespace`);
|
|
1352
1377
|
return value;
|
|
1353
1378
|
}
|
|
1354
|
-
const LOOPBACK_HOSTNAMES = new Set([
|
|
1379
|
+
const LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
1355
1380
|
"127.0.0.1",
|
|
1356
1381
|
"localhost",
|
|
1357
1382
|
"[::1]"
|
|
@@ -1433,9 +1458,10 @@ function sha256HexToBase64(hash) {
|
|
|
1433
1458
|
//#region src/storage/s3/primitives.ts
|
|
1434
1459
|
const defaultPresigner = (client, command, expiresInSeconds) => getSignedUrl(client, command, {
|
|
1435
1460
|
expiresIn: expiresInSeconds,
|
|
1436
|
-
unhoistableHeaders: new Set(["x-amz-checksum-sha256"])
|
|
1461
|
+
unhoistableHeaders: /* @__PURE__ */ new Set(["x-amz-checksum-sha256"])
|
|
1437
1462
|
});
|
|
1438
1463
|
var S3AttachmentPrimitives = class {
|
|
1464
|
+
config;
|
|
1439
1465
|
client;
|
|
1440
1466
|
presign;
|
|
1441
1467
|
now;
|
|
@@ -1506,7 +1532,7 @@ function createS3AttachmentPrimitives(config, dependencies = {}) {
|
|
|
1506
1532
|
//#endregion
|
|
1507
1533
|
//#region src/storage/s3/backend.ts
|
|
1508
1534
|
const READINESS_PROBE_HASH = "0".repeat(64);
|
|
1509
|
-
const OBJECT_NOT_FOUND_NAMES = new Set([
|
|
1535
|
+
const OBJECT_NOT_FOUND_NAMES = /* @__PURE__ */ new Set([
|
|
1510
1536
|
"NotFound",
|
|
1511
1537
|
"NoSuchKey",
|
|
1512
1538
|
"NoSuchObject"
|
|
@@ -1524,6 +1550,8 @@ function requireHashFirstReservation(reservation) {
|
|
|
1524
1550
|
}
|
|
1525
1551
|
/** Server-only S3 capability. Callers complete authorization before download. */
|
|
1526
1552
|
var S3AttachmentBackend = class {
|
|
1553
|
+
db;
|
|
1554
|
+
config;
|
|
1527
1555
|
kind = "s3";
|
|
1528
1556
|
primitives;
|
|
1529
1557
|
now;
|