@powerhousedao/reactor-attachments 6.2.3-dev.34 → 6.2.3-dev.36
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 +23 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -3
- 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 +5 -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;
|
|
@@ -184,6 +199,8 @@ interface IAttachmentReferenceReader {
|
|
|
184
199
|
}
|
|
185
200
|
interface IAttachmentReferenceWriter {
|
|
186
201
|
addReferences(references: readonly AttachmentReferenceInput[]): Promise<void>;
|
|
202
|
+
/** Deletes every reference of the documents; for a purged document. */
|
|
203
|
+
removeDocuments(documentIds: readonly string[]): Promise<void>;
|
|
187
204
|
}
|
|
188
205
|
//#endregion
|
|
189
206
|
//#region src/read-models/attachment-reference/index-builder.d.ts
|
|
@@ -204,6 +221,9 @@ export declare const ATTACHMENT_REFERENCE_READ_MODEL_ID = "attachment-reference-
|
|
|
204
221
|
* Each reference row stands on its own and is written insert-or-do-nothing, so
|
|
205
222
|
* a batch that commits in pieces exposes no partial structure, and re-indexing
|
|
206
223
|
* the same range writes nothing new: the catch-up sweep needs no stream suffix.
|
|
224
|
+
*
|
|
225
|
+
* The rows live on another handle, so the purge fence is "skip": a tombstoned
|
|
226
|
+
* id's operations are dropped at commit and its marker deletes its rows.
|
|
207
227
|
*/
|
|
208
228
|
export declare class AttachmentReferenceReadModel extends BaseReadModel {
|
|
209
229
|
private readonly documentModelRegistry;
|
|
@@ -235,6 +255,7 @@ export declare class KyselyAttachmentReferenceStore implements IAttachmentRefere
|
|
|
235
255
|
hasReference(documentId: string, ref: AttachmentRef): Promise<boolean>;
|
|
236
256
|
referencingScopes(documentId: string, ref: AttachmentRef): Promise<string[]>;
|
|
237
257
|
addReferences(references: readonly AttachmentReferenceInput[]): Promise<void>;
|
|
258
|
+
removeDocuments(documentIds: readonly string[]): Promise<void>;
|
|
238
259
|
}
|
|
239
260
|
//#endregion
|
|
240
261
|
//#region src/read-models/attachment-reference/storage/migrations/migrator.d.ts
|
|
@@ -335,6 +356,6 @@ export declare class S3AttachmentUploadFactory implements IAttachmentUploadFacto
|
|
|
335
356
|
createUpload(reservation: Reservation): IAttachmentUpload;
|
|
336
357
|
}
|
|
337
358
|
//#endregion
|
|
338
|
-
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 };
|
|
339
360
|
export {};
|
|
340
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/s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,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";
|
|
@@ -10,6 +10,7 @@ import { generatorTypeDefs } from "@powerhousedao/document-engineering/graphql";
|
|
|
10
10
|
import { constantCase, pascalCase } from "change-case";
|
|
11
11
|
import { Kind, buildASTSchema, getNamedType, isInputObjectType, isListType, isNonNullType, parse, print } from "graphql";
|
|
12
12
|
import { BaseReadModel, defaultReadModelIndexingConfig } from "@powerhousedao/reactor";
|
|
13
|
+
import { isPurgeMarker } from "@powerhousedao/shared/document-model";
|
|
13
14
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
14
15
|
import { GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
15
16
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
@@ -25,6 +26,27 @@ var __exportAll = (all, no_symbols) => {
|
|
|
25
26
|
return target;
|
|
26
27
|
};
|
|
27
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
|
|
28
50
|
//#region src/storage/fs/attachment-fs.ts
|
|
29
51
|
/**
|
|
30
52
|
* Compute the relative storage path for an attachment hash.
|
|
@@ -1102,6 +1124,10 @@ var KyselyAttachmentReferenceStore = class {
|
|
|
1102
1124
|
created_at_utc: (/* @__PURE__ */ new Date()).toISOString()
|
|
1103
1125
|
}))).onConflict((oc) => oc.columns(["document_id", "attachment_ref"]).doNothing()).execute();
|
|
1104
1126
|
}
|
|
1127
|
+
async removeDocuments(documentIds) {
|
|
1128
|
+
if (documentIds.length === 0) return;
|
|
1129
|
+
await this.db.deleteFrom("attachment_reference").where("document_id", "in", [...documentIds]).execute();
|
|
1130
|
+
}
|
|
1105
1131
|
};
|
|
1106
1132
|
//#endregion
|
|
1107
1133
|
//#region src/read-models/attachment-reference/storage/migrations/001_create_attachment_reference_table.ts
|
|
@@ -1199,6 +1225,9 @@ const ATTACHMENT_REFERENCE_READ_MODEL_ID = "attachment-reference-read-model";
|
|
|
1199
1225
|
* Each reference row stands on its own and is written insert-or-do-nothing, so
|
|
1200
1226
|
* a batch that commits in pieces exposes no partial structure, and re-indexing
|
|
1201
1227
|
* the same range writes nothing new: the catch-up sweep needs no stream suffix.
|
|
1228
|
+
*
|
|
1229
|
+
* The rows live on another handle, so the purge fence is "skip": a tombstoned
|
|
1230
|
+
* id's operations are dropped at commit and its marker deletes its rows.
|
|
1202
1231
|
*/
|
|
1203
1232
|
var AttachmentReferenceReadModel = class extends BaseReadModel {
|
|
1204
1233
|
documentModelRegistry;
|
|
@@ -1209,7 +1238,8 @@ var AttachmentReferenceReadModel = class extends BaseReadModel {
|
|
|
1209
1238
|
readModelId: ATTACHMENT_REFERENCE_READ_MODEL_ID,
|
|
1210
1239
|
rebuildStateOnInit: false,
|
|
1211
1240
|
indexing: defaultReadModelIndexingConfig,
|
|
1212
|
-
replayStreamSuffix: false
|
|
1241
|
+
replayStreamSuffix: false,
|
|
1242
|
+
purgeFence: "skip"
|
|
1213
1243
|
});
|
|
1214
1244
|
this.documentModelRegistry = documentModelRegistry;
|
|
1215
1245
|
this.schemaCompiler = schemaCompiler;
|
|
@@ -1217,7 +1247,12 @@ var AttachmentReferenceReadModel = class extends BaseReadModel {
|
|
|
1217
1247
|
}
|
|
1218
1248
|
async commitOperations(items) {
|
|
1219
1249
|
const references = [];
|
|
1250
|
+
const purged = /* @__PURE__ */ new Set();
|
|
1220
1251
|
for (const { operation, context } of items) {
|
|
1252
|
+
if (isPurgeMarker(operation)) {
|
|
1253
|
+
purged.add(context.documentId);
|
|
1254
|
+
continue;
|
|
1255
|
+
}
|
|
1221
1256
|
if (operation.error !== void 0) continue;
|
|
1222
1257
|
const module = this.documentModelRegistry.getModule(context.documentType);
|
|
1223
1258
|
const refs = this.schemaCompiler.forModuleAction(module, operation.action.type).extract(operation.action);
|
|
@@ -1231,6 +1266,7 @@ var AttachmentReferenceReadModel = class extends BaseReadModel {
|
|
|
1231
1266
|
});
|
|
1232
1267
|
}
|
|
1233
1268
|
if (references.length > 0) await this.referenceWriter.addReferences(references);
|
|
1269
|
+
if (purged.size > 0) await this.referenceWriter.removeDocuments([...purged]);
|
|
1234
1270
|
}
|
|
1235
1271
|
};
|
|
1236
1272
|
//#endregion
|
|
@@ -1507,6 +1543,6 @@ function createS3AttachmentBackend(db, config, dependencies = {}) {
|
|
|
1507
1543
|
return new S3AttachmentBackend(db, config, dependencies);
|
|
1508
1544
|
}
|
|
1509
1545
|
//#endregion
|
|
1510
|
-
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 };
|
|
1511
1547
|
|
|
1512
1548
|
//# sourceMappingURL=index.js.map
|