@powerhousedao/reactor-attachments 6.2.2-dev.50 → 6.2.2-dev.51
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 +177 -14
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +321 -60
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/{null-attachment-transport-D1Bj3hLU.d.ts → null-attachment-transport-CMrO_ZKA.d.ts} +103 -5
- package/dist/null-attachment-transport-CMrO_ZKA.d.ts.map +1 -0
- package/dist/{null-attachment-transport-CTBrRCDe.js → null-attachment-transport-CrsUafCi.js} +126 -11
- package/dist/null-attachment-transport-CrsUafCi.js.map +1 -0
- package/package.json +3 -3
- package/dist/null-attachment-transport-CTBrRCDe.js.map +0 -1
- package/dist/null-attachment-transport-D1Bj3hLU.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
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-CMrO_ZKA.js";
|
|
2
2
|
import * as kysely from "kysely";
|
|
3
3
|
import { Kysely } from "kysely";
|
|
4
4
|
import { AttachmentHash, AttachmentRef, BaseReadModel, DocumentViewDatabase, IConsistencyTracker, IDocumentModelRegistry, IOperationIndex, IWriteCache } from "@powerhousedao/reactor";
|
|
@@ -84,7 +84,7 @@ declare class DirectAttachmentUpload implements IAttachmentUpload {
|
|
|
84
84
|
readonly ref: AttachmentRef | null;
|
|
85
85
|
readonly expiresAtUtc: string;
|
|
86
86
|
constructor(reservation: Reservation, db: Kysely<AttachmentDatabase>, basePath: string, reservations: IReservationStore, maxBytes?: number | undefined);
|
|
87
|
-
send(data: ReadableStream<Uint8Array
|
|
87
|
+
send(data: ReadableStream<Uint8Array>, options?: AttachmentSendOptions): Promise<AttachmentUploadResult>;
|
|
88
88
|
}
|
|
89
89
|
//#endregion
|
|
90
90
|
//#region src/direct/direct-attachment-upload-factory.d.ts
|
|
@@ -332,5 +332,5 @@ declare class S3AttachmentUploadFactory implements IAttachmentUploadFactory {
|
|
|
332
332
|
createUpload(reservation: Reservation): IAttachmentUpload;
|
|
333
333
|
}
|
|
334
334
|
//#endregion
|
|
335
|
-
export { ATTACHMENT_REFERENCE_MIGRATION_LOCK_TABLE, ATTACHMENT_REFERENCE_MIGRATION_TABLE, ATTACHMENT_REFERENCE_READ_MODEL_ID, ATTACHMENT_REFERENCE_SCHEMA, ATTACHMENT_SCHEMA, AttachmentAlreadyExists, type AttachmentBackendHealth, type AttachmentBackendKind, type AttachmentBuildResult, AttachmentBuilder, type AttachmentDatabase, type AttachmentDownloadOptions, type AttachmentDownloadTarget, type AttachmentHeader, type AttachmentMetadata, AttachmentNotFound, AttachmentPending, type AttachmentReferenceIndexBuildResult, AttachmentReferenceIndexBuilder, type AttachmentReferenceInput, type AttachmentReferenceMigrationResult, AttachmentReferenceReadModel, type AttachmentResponse, AttachmentSchemaCompiler, AttachmentService, type AttachmentStatus, type AttachmentStorageConfig, type AttachmentTargetHeaders, AttachmentTransferError, type AttachmentTransferStage, type AttachmentTransportConfig, type AttachmentUploadResult, type AttachmentUploadTarget, type CompiledAttachmentExtractor, DEFAULT_RESERVATION_TTL_MS, DEFAULT_S3_ATTACHMENT_PREFIX, DEFAULT_S3_DOWNLOAD_TTL_SECONDS, DEFAULT_S3_UPLOAD_TTL_SECONDS, DirectAttachmentUpload, DirectAttachmentUploadFactory, FilesystemAttachmentBackend, 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, KyselyAttachmentReferenceStore, KyselyAttachmentStore, KyselyReservationStore, MAX_S3_PRESIGN_TTL_SECONDS, NullAttachmentTransport, type ParsedRef, RemoteAttachmentStore, RemoteAttachmentUpload, RemoteAttachmentUploadFactory, RemoteReservationStore, type Reservation, ReservationNotFound, type ReserveAttachmentOptions, S3AttachmentBackend, type S3AttachmentBackendDependencies, type S3AttachmentConfig, S3AttachmentPrimitives, S3AttachmentUploadFactory, type S3CommandClient, type S3Presigner, SizeMismatch, SwitchboardAttachmentTransport, type SwitchboardClientConfig, type SwitchboardTransportConfig, type TransportFetchResult, type TransportResponse, type UploadFirstReserveAttachmentOptions, UploadTooLarge, createRef, createRemoteAttachmentService, createS3AttachmentBackend, createS3AttachmentPrimitives, deriveS3AttachmentKey, getAttachmentReferenceMigrationStatus, normalizeS3AttachmentPrefix, parseAttachmentDownloadTarget, parseAttachmentStorageConfig, parseAttachmentUploadTarget, parseRef, rollbackAttachmentReferenceMigration, runAttachmentMigrations, runAttachmentReferenceMigrations, sha256HexToBase64 };
|
|
335
|
+
export { ATTACHMENT_REFERENCE_MIGRATION_LOCK_TABLE, ATTACHMENT_REFERENCE_MIGRATION_TABLE, ATTACHMENT_REFERENCE_READ_MODEL_ID, ATTACHMENT_REFERENCE_SCHEMA, ATTACHMENT_SCHEMA, AttachmentAlreadyExists, type AttachmentBackendHealth, type AttachmentBackendKind, type AttachmentBuildResult, AttachmentBuilder, type AttachmentDatabase, type AttachmentDownloadOptions, type AttachmentDownloadTarget, type AttachmentHeader, type AttachmentMetadata, AttachmentNotFound, AttachmentPending, type AttachmentReferenceIndexBuildResult, AttachmentReferenceIndexBuilder, type AttachmentReferenceInput, type AttachmentReferenceMigrationResult, AttachmentReferenceReadModel, type AttachmentResponse, AttachmentSchemaCompiler, 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, DEFAULT_RESERVATION_TTL_MS, DEFAULT_S3_ATTACHMENT_PREFIX, DEFAULT_S3_DOWNLOAD_TTL_SECONDS, DEFAULT_S3_UPLOAD_TTL_SECONDS, DirectAttachmentUpload, DirectAttachmentUploadFactory, FilesystemAttachmentBackend, 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, KyselyAttachmentReferenceStore, KyselyAttachmentStore, KyselyReservationStore, MAX_S3_PRESIGN_TTL_SECONDS, NullAttachmentTransport, type ParsedRef, RemoteAttachmentStore, RemoteAttachmentUpload, RemoteAttachmentUploadFactory, RemoteReservationStore, type Reservation, ReservationNotFound, type ReserveAttachmentOptions, S3AttachmentBackend, type S3AttachmentBackendDependencies, type S3AttachmentConfig, S3AttachmentPrimitives, S3AttachmentUploadFactory, type S3CommandClient, type S3Presigner, SizeMismatch, SwitchboardAttachmentTransport, type SwitchboardClientConfig, type SwitchboardTransportConfig, type TransportFetchResult, type TransportResponse, type UploadFirstReserveAttachmentOptions, UploadTooLarge, type XhrUploadTransportOptions, createFetchUploadTransport, createRef, createRemoteAttachmentService, createS3AttachmentBackend, createS3AttachmentPrimitives, createXhrUploadTransport, deriveS3AttachmentKey, getAttachmentReferenceMigrationStatus, normalizeS3AttachmentPrefix, parseAttachmentDownloadTarget, parseAttachmentStorageConfig, parseAttachmentUploadTarget, parseRef, rollbackAttachmentReferenceMigration, runAttachmentMigrations, runAttachmentReferenceMigrations, sha256HexToBase64 };
|
|
336
336
|
//# 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":";;;;;;;UAEiB,eAAA;EACf,IAAA;EACA,SAAA;EACA,SAAA;EACA,UAAA;EACA,SAAA;EACA,MAAA;EACA,YAAA;EACA,MAAA;EACA,cAAA;EACA,oBAAA;AAAA;AAAA,UAGe,0BAAA;EACf,cAAA;EACA,SAAA;EACA,SAAA;EACA,SAAA;EACA,cAAA;EACA,cAAA;EACA,cAAA;EACA,WAAA;EACA,UAAA;AAAA;AAAA,UAGe,kBAAA;EACf,UAAA,EAAY,eAAA;EACZ,sBAAA,EAAwB,0BAAA;AAAA;;;cC4Cb,qBAAA,YAAiC,gBAAA;EAAA,iBAIzB,EAAA;EAAA,iBACA,SAAA;EAAA,iBACA,QAAA;EAAA,iBALF,aAAA;cAGE,EAAA,EAAI,MAAA,CAAO,kBAAA,GACX,SAAA,EAAW,oBAAA,EACX,QAAA;EAGb,IAAA,CAAK,IAAA,EAAM,cAAA,GAAiB,OAAA,CAAQ,gBAAA;EAgCpC,GAAA,CAAI,IAAA,EAAM,cAAA,GAAiB,OAAA;EAU3B,GAAA,CACJ,IAAA,EAAM,cAAA,EACN,MAAA,GAAS,WAAA,GACR,OAAA,CAAQ,kBAAA;EA+DL,GAAA,CACJ,IAAA,EAAM,cAAA,EACN,QAAA,EAAU,kBAAA,EACV,IAAA,EAAM,cAAA,CAAe,UAAA,IACpB,OAAA;EAiDG,KAAA,CAAM,IAAA,EAAM,cAAA,GAAiB,OAAA;EAyB7B,WAAA,CAAA,GAAe,OAAA;EAAA,QAYP,sBAAA;EAAA,QAyCN,aAAA;EAAA,QAIA,aAAA;EAAA,QASA,gBAAA;AAAA;;;cCvUG,0BAAA;AAAA,cAeA,sBAAA,YAAkC,iBAAA;EAAA,iBAI1B,EAAA;EAAA,iBAHF,KAAA;cAGE,EAAA,EAAI,MAAA,CAAO,kBAAA,GAC5B,KAAA;EAKI,MAAA,CAAO,OAAA,EAAS,wBAAA,GAA2B,OAAA,CAAQ,WAAA;EAwBnD,GAAA,CAAI,aAAA,WAAwB,OAAA,CAAQ,WAAA;EAepC,MAAA,CAAO,aAAA,WAAwB,OAAA;EAS/B,aAAA,CAAc,GAAA,GAAK,IAAA,GAAoB,OAAA;AAAA;;;cCtElC,iBAAA;AAAA,UAEI,eAAA;EACf,OAAA;EACA,kBAAA;EACA,KAAA,GAAQ,KAAA;AAAA;AAAA,iBAkBY,uBAAA,CACpB,EAAA,EAAI,MAAA,OACJ,MAAA,YACC,OAAA,CAAQ,eAAA;;;
|
|
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,eAAA;EACf,IAAA;EACA,SAAA;EACA,SAAA;EACA,UAAA;EACA,SAAA;EACA,MAAA;EACA,YAAA;EACA,MAAA;EACA,cAAA;EACA,oBAAA;AAAA;AAAA,UAGe,0BAAA;EACf,cAAA;EACA,SAAA;EACA,SAAA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ACJ,IAAA,UACA,QAAA,UACA,UAAA,YACC,OAAA,CAAQ,sBAAA;EAqBL,oBAAA,CACJ,IAAA,UACA,UAAA,YACC,OAAA,CAAQ,wBAAA;AAAA;AAAA,iBAkBG,4BAAA,CACd,MAAA,EAAQ,kBAAA,EACR,YAAA,GAAc,YAAA,GACb,sBAAA;;;KClHS,+BAAA;EACV,MAAA,GAAS,eAAA;EACT,OAAA,GAAU,WAAA;EACV,GAAA,SAAY,IAAA;EACZ,gBAAA;EACA,kBAAA;AAAA;;cAkCW,mBAAA,YAA+B,kBAAA;EAAA,iBAQvB,EAAA;EAAA,SACR,MAAA,EAAQ,kBAAA;EAAA,SARV,IAAA;EAAA,iBACQ,UAAA;EAAA,iBACA,GAAA;EAAA,iBACA,gBAAA;EAAA,iBACA,kBAAA;cAGE,EAAA,EAAI,MAAA,CAAO,kBAAA,GACnB,MAAA,EAAQ,kBAAA,EACjB,YAAA,GAAc,+BAAA;EAUV,mBAAA,CACJ,WAAA,EAAa,WAAA,GACZ,OAAA,CAAQ,sBAAA;EAqDL,qBAAA,CACJ,IAAA,EAAM,cAAA,EACN,UAAA,YACC,OAAA,CAAQ,wBAAA;EAWL,MAAA,CAAO,IAAA,EAAM,cAAA,GAAiB,OAAA;EAoB9B,MAAA,CAAA,GAAU,OAAA,CAAQ,uBAAA;AAAA;AAAA,iBAaV,yBAAA,CACd,EAAA,EAAI,MAAA,CAAO,kBAAA,GACX,MAAA,EAAQ,kBAAA,EACR,YAAA,GAAc,+BAAA,GACb,mBAAA;;;cC7JU,yBAAA,YAAqC,wBAAA;EAChD,YAAA,CAAa,WAAA,EAAa,WAAA,GAAc,iBAAA;AAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
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-CrsUafCi.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";
|
|
@@ -98,19 +98,29 @@ async function deleteAttachmentBytes(path) {
|
|
|
98
98
|
* stream. At stream end, if the count does not equal the declaration,
|
|
99
99
|
* `SizeMismatch` is thrown. Both the `maxBytes` and `declaredSizeBytes`
|
|
100
100
|
* checks apply; `maxBytes` is evaluated first on each chunk.
|
|
101
|
+
*
|
|
102
|
+
* If `signal` aborts, the temp file is removed and the signal's reason is
|
|
103
|
+
* thrown. Nothing partial is ever returned, so a cancelled transfer cannot be
|
|
104
|
+
* committed.
|
|
101
105
|
*/
|
|
102
106
|
async function streamHashAndWrite(basePath, data, options = {}) {
|
|
103
|
-
const { maxBytes, declaredSizeBytes } = options;
|
|
107
|
+
const { maxBytes, declaredSizeBytes, signal } = options;
|
|
108
|
+
signal?.throwIfAborted();
|
|
104
109
|
const tmpDir = join(basePath, ".tmp");
|
|
105
110
|
await mkdir(tmpDir, { recursive: true });
|
|
106
111
|
const tempPath = join(tmpDir, randomUUID());
|
|
107
112
|
const hasher = createHash("sha256");
|
|
108
113
|
const writer = createWriteStream(tempPath);
|
|
109
114
|
const reader = data.getReader();
|
|
115
|
+
const onAbort = () => {
|
|
116
|
+
reader.cancel(signal?.reason).catch(() => {});
|
|
117
|
+
};
|
|
118
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
110
119
|
let sizeBytes = 0;
|
|
111
120
|
let caughtError;
|
|
112
121
|
try {
|
|
113
122
|
for (;;) {
|
|
123
|
+
signal?.throwIfAborted();
|
|
114
124
|
const { done, value } = await reader.read();
|
|
115
125
|
if (done) break;
|
|
116
126
|
sizeBytes += value.byteLength;
|
|
@@ -130,9 +140,11 @@ async function streamHashAndWrite(basePath, data, options = {}) {
|
|
|
130
140
|
writer.once("error", onError);
|
|
131
141
|
});
|
|
132
142
|
}
|
|
143
|
+
signal?.throwIfAborted();
|
|
133
144
|
} catch (err) {
|
|
134
145
|
caughtError = err instanceof Error ? err : new Error(String(err));
|
|
135
146
|
} finally {
|
|
147
|
+
signal?.removeEventListener("abort", onAbort);
|
|
136
148
|
reader.releaseLock();
|
|
137
149
|
}
|
|
138
150
|
let endError;
|
|
@@ -562,12 +574,13 @@ var DirectAttachmentUpload = class {
|
|
|
562
574
|
this.ref = reservation.clientHash != null ? createRef(reservation.clientHash) : null;
|
|
563
575
|
this.expiresAtUtc = reservation.expiresAtUtc;
|
|
564
576
|
}
|
|
565
|
-
async send(data) {
|
|
577
|
+
async send(data, options) {
|
|
566
578
|
if (this.reservation.clientHash != null && this.reservation.sizeBytes == null) throw new Error("hash-first reservation missing sizeBytes");
|
|
567
579
|
const declaredSizeBytes = this.reservation.clientHash != null ? this.reservation.sizeBytes ?? void 0 : void 0;
|
|
568
580
|
const { tempPath, hash, sizeBytes } = await streamHashAndWrite(this.basePath, data, {
|
|
569
581
|
maxBytes: this.maxBytes,
|
|
570
|
-
declaredSizeBytes
|
|
582
|
+
declaredSizeBytes,
|
|
583
|
+
...options?.signal ? { signal: options.signal } : {}
|
|
571
584
|
});
|
|
572
585
|
if (this.reservation.clientHash != null && hash !== this.reservation.clientHash) {
|
|
573
586
|
await rm(tempPath, { force: true });
|
|
@@ -1472,6 +1485,6 @@ function createS3AttachmentBackend(db, config, dependencies = {}) {
|
|
|
1472
1485
|
return new S3AttachmentBackend(db, config, dependencies);
|
|
1473
1486
|
}
|
|
1474
1487
|
//#endregion
|
|
1475
|
-
export { ATTACHMENT_REFERENCE_MIGRATION_LOCK_TABLE, ATTACHMENT_REFERENCE_MIGRATION_TABLE, ATTACHMENT_REFERENCE_READ_MODEL_ID, ATTACHMENT_REFERENCE_SCHEMA, ATTACHMENT_SCHEMA, AttachmentAlreadyExists, AttachmentBuilder, AttachmentNotFound, AttachmentPending, AttachmentReferenceIndexBuilder, AttachmentReferenceReadModel, AttachmentSchemaCompiler, AttachmentService, AttachmentTransferError, DEFAULT_RESERVATION_TTL_MS, DEFAULT_S3_ATTACHMENT_PREFIX, DEFAULT_S3_DOWNLOAD_TTL_SECONDS, DEFAULT_S3_UPLOAD_TTL_SECONDS, DirectAttachmentUpload, DirectAttachmentUploadFactory, FilesystemAttachmentBackend, HashMismatch, InvalidAttachmentRef, KyselyAttachmentReferenceStore, KyselyAttachmentStore, KyselyReservationStore, MAX_S3_PRESIGN_TTL_SECONDS, NullAttachmentTransport, RemoteAttachmentStore, RemoteAttachmentUpload, RemoteAttachmentUploadFactory, RemoteReservationStore, ReservationNotFound, S3AttachmentBackend, S3AttachmentPrimitives, S3AttachmentUploadFactory, SizeMismatch, SwitchboardAttachmentTransport, UploadTooLarge, createRef, createRemoteAttachmentService, createS3AttachmentBackend, createS3AttachmentPrimitives, deriveS3AttachmentKey, getAttachmentReferenceMigrationStatus, normalizeS3AttachmentPrefix, parseAttachmentDownloadTarget, parseAttachmentStorageConfig, parseAttachmentUploadTarget, parseRef, rollbackAttachmentReferenceMigration, runAttachmentMigrations, runAttachmentReferenceMigrations, sha256HexToBase64 };
|
|
1488
|
+
export { ATTACHMENT_REFERENCE_MIGRATION_LOCK_TABLE, ATTACHMENT_REFERENCE_MIGRATION_TABLE, ATTACHMENT_REFERENCE_READ_MODEL_ID, ATTACHMENT_REFERENCE_SCHEMA, ATTACHMENT_SCHEMA, AttachmentAlreadyExists, AttachmentBuilder, AttachmentNotFound, AttachmentPending, AttachmentReferenceIndexBuilder, AttachmentReferenceReadModel, AttachmentSchemaCompiler, AttachmentService, AttachmentTransferError, DEFAULT_RESERVATION_TTL_MS, DEFAULT_S3_ATTACHMENT_PREFIX, DEFAULT_S3_DOWNLOAD_TTL_SECONDS, DEFAULT_S3_UPLOAD_TTL_SECONDS, DirectAttachmentUpload, DirectAttachmentUploadFactory, FilesystemAttachmentBackend, HashMismatch, InvalidAttachmentRef, KyselyAttachmentReferenceStore, KyselyAttachmentStore, KyselyReservationStore, MAX_S3_PRESIGN_TTL_SECONDS, NullAttachmentTransport, RemoteAttachmentStore, RemoteAttachmentUpload, RemoteAttachmentUploadFactory, RemoteReservationStore, ReservationNotFound, S3AttachmentBackend, S3AttachmentPrimitives, S3AttachmentUploadFactory, SizeMismatch, SwitchboardAttachmentTransport, UploadTooLarge, createFetchUploadTransport, createRef, createRemoteAttachmentService, createS3AttachmentBackend, createS3AttachmentPrimitives, createXhrUploadTransport, deriveS3AttachmentKey, getAttachmentReferenceMigrationStatus, normalizeS3AttachmentPrefix, parseAttachmentDownloadTarget, parseAttachmentStorageConfig, parseAttachmentUploadTarget, parseRef, rollbackAttachmentReferenceMigration, runAttachmentMigrations, runAttachmentReferenceMigrations, sha256HexToBase64 };
|
|
1476
1489
|
|
|
1477
1490
|
//# sourceMappingURL=index.js.map
|