@powerhousedao/reactor-attachments 6.2.3-dev.35 → 6.2.3-dev.37
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 +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/dist/{null-attachment-transport-D53Rz9lE.js → null-attachment-transport-CUDNBfd5.js} +14 -2
- package/dist/null-attachment-transport-CUDNBfd5.js.map +1 -0
- package/dist/{null-attachment-transport-BkM6rq4R.d.ts → null-attachment-transport-jZmzFncu.d.ts} +12 -2
- package/dist/null-attachment-transport-jZmzFncu.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/null-attachment-transport-BkM6rq4R.d.ts.map +0 -1
- package/dist/null-attachment-transport-D53Rz9lE.js.map +0 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as IReservationStore, B as AttachmentStatOptions, C as IAttachmentReader, D as IAttachmentTransportFactory, E as IAttachmentTransport, F as AttachmentDownloadTargetOptions, G as AttachmentUploadTarget, H as AttachmentTargetHeaders, I as AttachmentHeader, J as ReserveAttachmentOptions, K as HashFirstReserveAttachmentOptions, L as AttachmentMetadata, N as AttachmentDownloadOptions, O as IAttachmentUpload, P as AttachmentDownloadTarget, Q as AttachmentAlreadyExists, R as AttachmentResponse, T as IAttachmentStore, U as AttachmentTransportConfig, V as AttachmentStatus, W as AttachmentUploadResult, X as TransportResponse, Y as TransportFetchResult, Z as UploadFirstReserveAttachmentOptions, _ as createRef, a as RemoteAttachmentUpload, b as parseAttachmentDownloadTarget, c as XhrUploadTransportOptions, ct as SizeMismatch, d as AttachmentUploadResponse, et as AttachmentNotFound, f as AttachmentUploadTransport, g as ParsedRef, h as SwitchboardTransportConfig, i as RemoteAttachmentUploadFactory, it as HashMismatch, k as IAttachmentUploadFactory, l as createXhrUploadTransport, lt as UploadTooLarge, m as SwitchboardAttachmentTransport, n as createRemoteAttachmentService, nt as AttachmentTransferError, o as RemoteReservationStore, ot as InvalidAttachmentRef, p as createFetchUploadTransport, q as Reservation, r as RemoteAttachmentStore, rt as AttachmentTransferStage, s as SwitchboardClientConfig, st as ReservationNotFound, t as NullAttachmentTransport, tt as AttachmentPending, u as AttachmentUploadRequest, v as parseRef, w as IAttachmentService, x as parseAttachmentUploadTarget, y as AttachmentService, z as AttachmentSendOptions } from "./null-attachment-transport-jZmzFncu.js";
|
|
2
2
|
import { AttachmentHash, AttachmentRef } from "@powerhousedao/reactor";
|
|
3
3
|
//#region src/concurrency.d.ts
|
|
4
4
|
/**
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as SizeMismatch, S as ReservationNotFound, _ as AttachmentPending, a as RemoteAttachmentUpload, 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, w as UploadTooLarge, x as InvalidAttachmentRef, y as HashMismatch } from "./null-attachment-transport-CUDNBfd5.js";
|
|
2
2
|
//#region src/concurrency.ts
|
|
3
3
|
/**
|
|
4
4
|
* Runs `worker` over `items` with a hard upper bound on simultaneous
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as AttachmentMetadataField, A as IReservationStore, B as AttachmentStatOptions, C as IAttachmentReader, D as IAttachmentTransportFactory, E as IAttachmentTransport, F as AttachmentDownloadTargetOptions, G as AttachmentUploadTarget, H as AttachmentTargetHeaders, I as AttachmentHeader, J as ReserveAttachmentOptions, K as HashFirstReserveAttachmentOptions, L as AttachmentMetadata, M as AttachmentBackendKind, N as AttachmentDownloadOptions, O as IAttachmentUpload, P as AttachmentDownloadTarget, Q as AttachmentAlreadyExists, R as AttachmentResponse, S as IAttachmentBackend, T as IAttachmentStore, U as AttachmentTransportConfig, V as AttachmentStatus, W as AttachmentUploadResult, X as TransportResponse, Y as TransportFetchResult, Z as UploadFirstReserveAttachmentOptions, _ as createRef, a as RemoteAttachmentUpload, at as InvalidAttachmentMetadata, b as parseAttachmentDownloadTarget, c as XhrUploadTransportOptions, ct as SizeMismatch, d as AttachmentUploadResponse, et as AttachmentNotFound, f as AttachmentUploadTransport, g as ParsedRef, h as SwitchboardTransportConfig, i as RemoteAttachmentUploadFactory, it as HashMismatch, j as AttachmentBackendHealth, k as IAttachmentUploadFactory, l as createXhrUploadTransport, lt as UploadTooLarge, m as SwitchboardAttachmentTransport, n as createRemoteAttachmentService, nt as AttachmentTransferError, o as RemoteReservationStore, ot as InvalidAttachmentRef, p as createFetchUploadTransport, q as Reservation, r as RemoteAttachmentStore, rt as AttachmentTransferStage, s as SwitchboardClientConfig, st as ReservationNotFound, t as NullAttachmentTransport, tt as AttachmentPending, u as AttachmentUploadRequest, v as parseRef, w as IAttachmentService, x as parseAttachmentUploadTarget, y as AttachmentService, z as AttachmentSendOptions } from "./null-attachment-transport-jZmzFncu.js";
|
|
2
2
|
import { Kysely } from "kysely";
|
|
3
3
|
import { AttachmentHash, AttachmentRef, BaseReadModel, DocumentViewDatabase, IConsistencyTracker, IDocumentModelRegistry, IOperationIndex, IWriteCache } from "@powerhousedao/reactor";
|
|
4
4
|
import { Action, DocumentModelModule, OperationWithContext } from "@powerhousedao/shared/document-model";
|
|
5
|
+
//#region src/reserve-metadata.d.ts
|
|
6
|
+
/** The descriptive fields of a reservation, as a caller supplies them. */
|
|
7
|
+
type ReserveMetadata = {
|
|
8
|
+
mimeType: string;
|
|
9
|
+
fileName: string;
|
|
10
|
+
extension?: string | null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Validates reserve metadata with the rules the switchboard reserve route
|
|
14
|
+
* applies.
|
|
15
|
+
*
|
|
16
|
+
* @throws InvalidAttachmentMetadata naming the first field that fails.
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateReserveMetadata(meta: ReserveMetadata): void;
|
|
19
|
+
//#endregion
|
|
5
20
|
//#region src/storage/kysely/types.d.ts
|
|
6
21
|
interface AttachmentTable {
|
|
7
22
|
hash: string;
|
|
@@ -341,6 +356,6 @@ export declare class S3AttachmentUploadFactory implements IAttachmentUploadFacto
|
|
|
341
356
|
createUpload(reservation: Reservation): IAttachmentUpload;
|
|
342
357
|
}
|
|
343
358
|
//#endregion
|
|
344
|
-
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 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, 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 };
|
|
359
|
+
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 };
|
|
345
360
|
export {};
|
|
346
361
|
//# 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/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/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":";;;;;;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,gBACN,SAAS,aACT,sBACC,QAAQ;EA+CL,IACJ,MAAM,gBACN,UAAU,oBACV,MAAM,eAAe,cACpB;EAiDG,MAAM,MAAM,iBAAiB;EAyB7B,eAAe;UAYP;UAmBA;UAyCN;UAIA;UASA;;;;qBC3UG;qBAeA,kCAAkC;mBAI1B;mBAHF;EAEjB,YACmB,IAAI,OAAO,qBAC5B;EAKI,OAAO,SAAS,2BAA2B,QAAQ;EAwBnD,IAAI,wBAAwB,QAAQ;EAepC,OAAO,wBAAwB;EAS/B,cAAc,MAAK,OAAoB;;;;qBCtElC;UAEI;EACf;EACA;EACA,QAAQ;;wBAkBY,wBACpB,IAAI,aACJ,kBACC,QAAQ;;;qBCEE,kCAAkC;mBAM1B;mBACA;mBACA;mBACA;mBACA;WATV;WACA,KAAK;WACL;EAET,YACmB,aAAa,aACb,IAAI,OAAO,qBACX,kBACA,cAAc,mBACd;EAQb,KACJ,MAAM,eAAe,aACrB,UAAU,wBACT,QAAQ;;;;qBCjDA,yCAAyC;mBAEjC;mBACA;mBACA;mBACA;EAJnB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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
|
|
1
|
+
import { C as SizeMismatch, S as ReservationNotFound, _ as AttachmentPending, a as RemoteAttachmentUpload, b as InvalidAttachmentMetadata, 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, w as UploadTooLarge, x as InvalidAttachmentRef, y as HashMismatch } from "./null-attachment-transport-CUDNBfd5.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";
|
|
@@ -26,6 +26,27 @@ var __exportAll = (all, no_symbols) => {
|
|
|
26
26
|
return target;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
|
+
//#region src/reserve-metadata.ts
|
|
30
|
+
const CONTROL_CHARS = /[\x00-\x1f\x7f]/;
|
|
31
|
+
const NON_HEADER_CHARS = /[^\t\x20-\x7e\x80-\xff]/;
|
|
32
|
+
const MIME_TYPE_PATTERN = /^[!#$%&'*+\-.^_`|~\w]+\/[!#$%&'*+\-.^_`|~\w]+(?:[ \t]*;[ \t]*[!#$%&'*+\-.^_`|~\w]+=(?:[!#$%&'*+\-.^_`|~\w]+|"(?:[^"\\\r\n]|\\[^\r\n])*"))*$/;
|
|
33
|
+
const MAX_FILENAME_LEN = 255;
|
|
34
|
+
const MAX_MIMETYPE_LEN = 255;
|
|
35
|
+
/**
|
|
36
|
+
* Validates reserve metadata with the rules the switchboard reserve route
|
|
37
|
+
* applies.
|
|
38
|
+
*
|
|
39
|
+
* @throws InvalidAttachmentMetadata naming the first field that fails.
|
|
40
|
+
*/
|
|
41
|
+
function validateReserveMetadata(meta) {
|
|
42
|
+
const { mimeType, fileName, extension } = meta;
|
|
43
|
+
if (typeof mimeType !== "string" || mimeType.length === 0 || mimeType.length > MAX_MIMETYPE_LEN || NON_HEADER_CHARS.test(mimeType) || !MIME_TYPE_PATTERN.test(mimeType)) throw new InvalidAttachmentMetadata("mimeType");
|
|
44
|
+
if (typeof fileName !== "string" || fileName.length === 0 || fileName.length > MAX_FILENAME_LEN || CONTROL_CHARS.test(fileName)) throw new InvalidAttachmentMetadata("fileName");
|
|
45
|
+
if (typeof extension === "string") {
|
|
46
|
+
if (extension.length === 0 || /[\\/]/.test(extension)) throw new InvalidAttachmentMetadata("extension");
|
|
47
|
+
} else if (extension !== void 0 && extension !== null) throw new InvalidAttachmentMetadata("extension");
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
29
50
|
//#region src/storage/fs/attachment-fs.ts
|
|
30
51
|
/**
|
|
31
52
|
* Compute the relative storage path for an attachment hash.
|
|
@@ -1522,6 +1543,6 @@ function createS3AttachmentBackend(db, config, dependencies = {}) {
|
|
|
1522
1543
|
return new S3AttachmentBackend(db, config, dependencies);
|
|
1523
1544
|
}
|
|
1524
1545
|
//#endregion
|
|
1525
|
-
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 };
|
|
1546
|
+
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, InvalidAttachmentMetadata, 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, validateReserveMetadata };
|
|
1526
1547
|
|
|
1527
1548
|
//# sourceMappingURL=index.js.map
|