@ddd-ts-kit/kernel 0.87.0 → 0.89.0
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/README.fr.md +46 -5
- package/README.md +45 -4
- package/dist/application/personal-data/assert-retention.d.ts +4 -0
- package/dist/application/personal-data/assert-retention.d.ts.map +1 -0
- package/dist/application/personal-data/assert-retention.js +12 -0
- package/dist/application/personal-data/assert-retention.js.map +1 -0
- package/dist/application/personal-data/data-subject-erased-definition.d.ts +33 -0
- package/dist/application/personal-data/data-subject-erased-definition.d.ts.map +1 -0
- package/dist/application/personal-data/data-subject-erased-definition.js +2 -0
- package/dist/application/personal-data/data-subject-erased-definition.js.map +1 -0
- package/dist/application/personal-data/data-subject-erased-parse-error.d.ts +15 -0
- package/dist/application/personal-data/data-subject-erased-parse-error.d.ts.map +1 -0
- package/dist/application/personal-data/data-subject-erased-parse-error.js +2 -0
- package/dist/application/personal-data/data-subject-erased-parse-error.js.map +1 -0
- package/dist/application/personal-data/data-subject-erased-payload.d.ts +12 -0
- package/dist/application/personal-data/data-subject-erased-payload.d.ts.map +1 -0
- package/dist/application/personal-data/data-subject-erased-payload.js +2 -0
- package/dist/application/personal-data/data-subject-erased-payload.js.map +1 -0
- package/dist/application/personal-data/data-subject-erased-v1.d.ts +13 -0
- package/dist/application/personal-data/data-subject-erased-v1.d.ts.map +1 -0
- package/dist/application/personal-data/data-subject-erased-v1.js +87 -0
- package/dist/application/personal-data/data-subject-erased-v1.js.map +1 -0
- package/dist/application/personal-data/data-subject-erasure-report.d.ts +7 -0
- package/dist/application/personal-data/data-subject-erasure-report.d.ts.map +1 -0
- package/dist/application/personal-data/data-subject-erasure-report.js +2 -0
- package/dist/application/personal-data/data-subject-erasure-report.js.map +1 -0
- package/dist/application/personal-data/data-subject-erasure.d.ts +31 -0
- package/dist/application/personal-data/data-subject-erasure.d.ts.map +1 -0
- package/dist/application/personal-data/data-subject-erasure.js +2 -0
- package/dist/application/personal-data/data-subject-erasure.js.map +1 -0
- package/dist/application/personal-data/data-subject-export.d.ts +23 -0
- package/dist/application/personal-data/data-subject-export.d.ts.map +1 -0
- package/dist/application/personal-data/data-subject-export.js +2 -0
- package/dist/application/personal-data/data-subject-export.js.map +1 -0
- package/dist/application/personal-data/each-tenant.d.ts +9 -0
- package/dist/application/personal-data/each-tenant.d.ts.map +1 -0
- package/dist/application/personal-data/each-tenant.js +16 -0
- package/dist/application/personal-data/each-tenant.js.map +1 -0
- package/dist/application/personal-data/erase-data-subject.d.ts +17 -0
- package/dist/application/personal-data/erase-data-subject.d.ts.map +1 -0
- package/dist/application/personal-data/erase-data-subject.js +75 -0
- package/dist/application/personal-data/erase-data-subject.js.map +1 -0
- package/dist/application/personal-data/erasure-mode.d.ts +7 -0
- package/dist/application/personal-data/erasure-mode.d.ts.map +1 -0
- package/dist/application/personal-data/erasure-mode.js +2 -0
- package/dist/application/personal-data/erasure-mode.js.map +1 -0
- package/dist/application/personal-data/expired-before.d.ts +4 -0
- package/dist/application/personal-data/expired-before.d.ts.map +1 -0
- package/dist/application/personal-data/expired-before.js +9 -0
- package/dist/application/personal-data/expired-before.js.map +1 -0
- package/dist/application/personal-data/export-data-subject.d.ts +15 -0
- package/dist/application/personal-data/export-data-subject.d.ts.map +1 -0
- package/dist/application/personal-data/export-data-subject.js +34 -0
- package/dist/application/personal-data/export-data-subject.js.map +1 -0
- package/dist/application/personal-data/in-each-tenant.d.ts +11 -0
- package/dist/application/personal-data/in-each-tenant.d.ts.map +1 -0
- package/dist/application/personal-data/in-each-tenant.js +13 -0
- package/dist/application/personal-data/in-each-tenant.js.map +1 -0
- package/dist/application/personal-data/index.d.ts +34 -0
- package/dist/application/personal-data/index.d.ts.map +1 -0
- package/dist/application/personal-data/index.js +34 -0
- package/dist/application/personal-data/index.js.map +1 -0
- package/dist/application/personal-data/invalid-data-subject-erased-error.d.ts +7 -0
- package/dist/application/personal-data/invalid-data-subject-erased-error.d.ts.map +1 -0
- package/dist/application/personal-data/invalid-data-subject-erased-error.js +10 -0
- package/dist/application/personal-data/invalid-data-subject-erased-error.js.map +1 -0
- package/dist/application/personal-data/invalid-personal-fields-error.d.ts +5 -0
- package/dist/application/personal-data/invalid-personal-fields-error.d.ts.map +1 -0
- package/dist/application/personal-data/invalid-personal-fields-error.js +8 -0
- package/dist/application/personal-data/invalid-personal-fields-error.js.map +1 -0
- package/dist/application/personal-data/is-data-subject-id.d.ts +7 -0
- package/dist/application/personal-data/is-data-subject-id.d.ts.map +1 -0
- package/dist/application/personal-data/is-data-subject-id.js +10 -0
- package/dist/application/personal-data/is-data-subject-id.js.map +1 -0
- package/dist/application/personal-data/is-personal-data-retention.d.ts +4 -0
- package/dist/application/personal-data/is-personal-data-retention.d.ts.map +1 -0
- package/dist/application/personal-data/is-personal-data-retention.js +8 -0
- package/dist/application/personal-data/is-personal-data-retention.js.map +1 -0
- package/dist/application/personal-data/not-a-data-subject-id-error.d.ts +5 -0
- package/dist/application/personal-data/not-a-data-subject-id-error.d.ts.map +1 -0
- package/dist/application/personal-data/not-a-data-subject-id-error.js +8 -0
- package/dist/application/personal-data/not-a-data-subject-id-error.js.map +1 -0
- package/dist/application/personal-data/payload-issue.d.ts +7 -0
- package/dist/application/personal-data/payload-issue.d.ts.map +1 -0
- package/dist/application/personal-data/payload-issue.js +2 -0
- package/dist/application/personal-data/payload-issue.js.map +1 -0
- package/dist/application/personal-data/personal-data-copy.d.ts +13 -0
- package/dist/application/personal-data/personal-data-copy.d.ts.map +1 -0
- package/dist/application/personal-data/personal-data-copy.js +2 -0
- package/dist/application/personal-data/personal-data-copy.js.map +1 -0
- package/dist/application/personal-data/personal-data-export-document.d.ts +20 -0
- package/dist/application/personal-data/personal-data-export-document.d.ts.map +1 -0
- package/dist/application/personal-data/personal-data-export-document.js +2 -0
- package/dist/application/personal-data/personal-data-export-document.js.map +1 -0
- package/dist/application/personal-data/personal-data-export-format.d.ts +8 -0
- package/dist/application/personal-data/personal-data-export-format.d.ts.map +1 -0
- package/dist/application/personal-data/personal-data-export-format.js +8 -0
- package/dist/application/personal-data/personal-data-export-format.js.map +1 -0
- package/dist/application/personal-data/personal-data-purge-report.d.ts +5 -0
- package/dist/application/personal-data/personal-data-purge-report.d.ts.map +1 -0
- package/dist/application/personal-data/personal-data-purge-report.js +2 -0
- package/dist/application/personal-data/personal-data-purge-report.js.map +1 -0
- package/dist/application/personal-data/personal-data-record.d.ts +8 -0
- package/dist/application/personal-data/personal-data-record.d.ts.map +1 -0
- package/dist/application/personal-data/personal-data-record.js +2 -0
- package/dist/application/personal-data/personal-data-record.js.map +1 -0
- package/dist/application/personal-data/personal-data-value-of.d.ts +4 -0
- package/dist/application/personal-data/personal-data-value-of.d.ts.map +1 -0
- package/dist/application/personal-data/personal-data-value-of.js +21 -0
- package/dist/application/personal-data/personal-data-value-of.js.map +1 -0
- package/dist/application/personal-data/personal-data-value.d.ts +3 -0
- package/dist/application/personal-data/personal-data-value.d.ts.map +1 -0
- package/dist/application/personal-data/personal-data-value.js +2 -0
- package/dist/application/personal-data/personal-data-value.js.map +1 -0
- package/dist/application/personal-data/personal-fields.d.ts +34 -0
- package/dist/application/personal-data/personal-fields.d.ts.map +1 -0
- package/dist/application/personal-data/personal-fields.js +28 -0
- package/dist/application/personal-data/personal-fields.js.map +1 -0
- package/dist/application/personal-data/projection-to-rebuild.d.ts +8 -0
- package/dist/application/personal-data/projection-to-rebuild.d.ts.map +1 -0
- package/dist/application/personal-data/projection-to-rebuild.js +2 -0
- package/dist/application/personal-data/projection-to-rebuild.js.map +1 -0
- package/dist/application/personal-data/purge-expired-personal-data.d.ts +9 -0
- package/dist/application/personal-data/purge-expired-personal-data.d.ts.map +1 -0
- package/dist/application/personal-data/purge-expired-personal-data.js +23 -0
- package/dist/application/personal-data/purge-expired-personal-data.js.map +1 -0
- package/dist/application/personal-data/records-in-each-tenant.d.ts +10 -0
- package/dist/application/personal-data/records-in-each-tenant.d.ts.map +1 -0
- package/dist/application/personal-data/records-in-each-tenant.js +11 -0
- package/dist/application/personal-data/records-in-each-tenant.js.map +1 -0
- package/dist/application/personal-data/retention-period.d.ts +7 -0
- package/dist/application/personal-data/retention-period.d.ts.map +1 -0
- package/dist/application/personal-data/retention-period.js +2 -0
- package/dist/application/personal-data/retention-period.js.map +1 -0
- package/dist/application/personal-data/retention.d.ts +13 -0
- package/dist/application/personal-data/retention.d.ts.map +1 -0
- package/dist/application/personal-data/retention.js +2 -0
- package/dist/application/personal-data/retention.js.map +1 -0
- package/dist/application/personal-data/unknown-data-subject-error.d.ts +6 -0
- package/dist/application/personal-data/unknown-data-subject-error.d.ts.map +1 -0
- package/dist/application/personal-data/unknown-data-subject-error.js +10 -0
- package/dist/application/personal-data/unknown-data-subject-error.js.map +1 -0
- package/dist/application/ports/personal-data-erasure.d.ts +14 -0
- package/dist/application/ports/personal-data-erasure.d.ts.map +1 -0
- package/dist/application/ports/personal-data-erasure.js +14 -0
- package/dist/application/ports/personal-data-erasure.js.map +1 -0
- package/dist/application/ports/personal-data-export.d.ts +13 -0
- package/dist/application/ports/personal-data-export.d.ts.map +1 -0
- package/dist/application/ports/personal-data-export.js +12 -0
- package/dist/application/ports/personal-data-export.js.map +1 -0
- package/dist/application/ports/personal-data-retention.d.ts +17 -0
- package/dist/application/ports/personal-data-retention.d.ts.map +1 -0
- package/dist/application/ports/personal-data-retention.js +13 -0
- package/dist/application/ports/personal-data-retention.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/in-memory/in-memory-personal-data.d.ts +38 -0
- package/dist/infrastructure/in-memory/in-memory-personal-data.d.ts.map +1 -0
- package/dist/infrastructure/in-memory/in-memory-personal-data.js +102 -0
- package/dist/infrastructure/in-memory/in-memory-personal-data.js.map +1 -0
- package/dist/infrastructure/personal-data/not-nullable-personal-column-error.d.ts +10 -0
- package/dist/infrastructure/personal-data/not-nullable-personal-column-error.d.ts.map +1 -0
- package/dist/infrastructure/personal-data/not-nullable-personal-column-error.js +13 -0
- package/dist/infrastructure/personal-data/not-nullable-personal-column-error.js.map +1 -0
- package/dist/infrastructure/personal-data/pseudonymised-value-of.d.ts +8 -0
- package/dist/infrastructure/personal-data/pseudonymised-value-of.d.ts.map +1 -0
- package/dist/infrastructure/personal-data/pseudonymised-value-of.js +12 -0
- package/dist/infrastructure/personal-data/pseudonymised-value-of.js.map +1 -0
- package/package.json +1 -1
package/README.fr.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](README.md) · **Français**
|
|
2
|
-
<!-- translation-of: README.md sha256:
|
|
2
|
+
<!-- translation-of: README.md sha256:298a9aa1069515a0 -->
|
|
3
3
|
|
|
4
4
|
# @ddd-ts-kit/kernel
|
|
5
5
|
|
|
@@ -45,6 +45,7 @@ avec une bibliothèque.
|
|
|
45
45
|
| Fichiers | `FileStorage`, `StoredFile`, `FileScanner`, `FileKeys`, `TenantFileKeys`, `FileStaging`, `FileUpload`, `fileUploadsMiddleware`, `FileInspection`, `FileError`, `InMemoryFileStorage`, `LocalFileStorage`, `PurgeStagedFiles` (voir « FileStorage, StoredFile, FileScanner ») |
|
|
46
46
|
| Multitenance | `tenantScopeOf`, `tenantReachOf`, `acrossTenants`, `tenantKey`, `tenantCacheKey`, `isTenantId`, `TenantDirectory`, `InMemoryTenantDirectory` (voir « Multitenance ») |
|
|
47
47
|
| *Event sourcing* | `EventSourcedAggregate`, `EventStore`, `defineStoredEvent`, `EventSerializer`, `EventSourcedRepository`, `SnapshotPolicy`, `personalData`, `PersonalDataCipher`, `CatchUpSubscription`, `EventStoreProjectionRebuild`, `InMemoryEventStore`, `PostgresEventStore` (voir « Event sourcing ») |
|
|
48
|
+
| Données personnelles | `personalFields`, `PersonalDataErasure`, `PersonalDataExport`, `eraseDataSubject`, `exportDataSubject`, `PersonalDataExportDocument`, `inEachTenant`, `recordsInEachTenant`, `isDataSubjectId`, `PersonalDataRecord`, `InMemoryPersonalData` (voir « Données personnelles ») |
|
|
48
49
|
| Côté lecture | `Criteria`, `defineCriteria`, `validateCriteria`, `scoped`, `planCriteria`, `evaluateCriteria`, `pageOfPlan`, `hydrate`, `ReadModelStore`, `stampOf`, `TableReadModelStore`, `ProjectionRebuild`, `InMemoryReadModelStore` (voir « Critères », « Hydratation » et « Projections ») |
|
|
49
50
|
| Aides à la persistance | `optimisticUpdate`, `expectVersion` (la version qu'un appelant a lue, `If-Match` en HTTP, est toujours la version courante, sinon `PreconditionFailedError` : 412), `schemaNameOf`, `stampCreation`, `stampUpdate`, `tenantScopeOf`, `encodeCursor`, `decodeCursor` |
|
|
50
51
|
| Remontée des erreurs | `ErrorReporter`, `ErrorReport`, `errorReportOf`, `reportOnce`, `isUnexpectedError`, `errorReportingMiddleware`, `DeadLetterReports`, `reportProcessFailures`, `NoopErrorReporter` |
|
|
@@ -62,7 +63,7 @@ chacun son propre fichier, et `ddd-ts-kit generate` les écrit) :
|
|
|
62
63
|
```ts
|
|
63
64
|
import { AggregateRoot, DomainRefusal, Entity, ValueObject, NamedDomainEvent } from '@ddd-ts-kit/kernel';
|
|
64
65
|
|
|
65
|
-
// Les codes du contexte, dans
|
|
66
|
+
// Les codes du contexte, dans <context>.codes.ts, et ses refus, une classe chacun (voir « Erreurs du domaine »).
|
|
66
67
|
export const OrderingCodes = {
|
|
67
68
|
InvalidQuantity: 'INVALID_QUANTITY',
|
|
68
69
|
OrderAlreadyPlaced: 'ORDER_ALREADY_PLACED',
|
|
@@ -211,7 +212,7 @@ Un refus métier est une `DomainError` : une réponse que le code a prévue, con
|
|
|
211
212
|
`code`. Un contexte a une classe par refus, nommée d'après ce qui est refusé, qui étend
|
|
212
213
|
`DomainRefusal` ; ses fabriques statiques sont nommées d'après ce sur quoi porte le refus, et le
|
|
213
214
|
code de chaque refus du contexte est écrit une seule fois, dans la liste fermée
|
|
214
|
-
|
|
215
|
+
`<context>.codes.ts` :
|
|
215
216
|
|
|
216
217
|
<!-- checked sample -->
|
|
217
218
|
```ts
|
|
@@ -220,7 +221,7 @@ import { DomainRefusal } from '@ddd-ts-kit/kernel';
|
|
|
220
221
|
declare const calendar: { readonly id: string };
|
|
221
222
|
declare const slot: { readonly startsAt: Date };
|
|
222
223
|
|
|
223
|
-
//
|
|
224
|
+
// scheduling.codes.ts
|
|
224
225
|
export const SchedulingCodes = {
|
|
225
226
|
SlotTaken: 'SLOT_TAKEN',
|
|
226
227
|
UnknownAppointment: 'APPOINTMENT_NOT_FOUND',
|
|
@@ -363,7 +364,7 @@ import { AggregateRoot, DomainRefusal, defineStateMachine } from '@ddd-ts-kit/ke
|
|
|
363
364
|
export const ParcelStatus = { Registered: 'registered', Shipped: 'shipped', Delivered: 'delivered' } as const;
|
|
364
365
|
export type ParcelStatus = (typeof ParcelStatus)[keyof typeof ParcelStatus];
|
|
365
366
|
|
|
366
|
-
//
|
|
367
|
+
// shipping.codes.ts, puis une classe par refus
|
|
367
368
|
export const ShippingCodes = {
|
|
368
369
|
ParcelUnpaid: 'PARCEL_UNPAID',
|
|
369
370
|
ParcelTransitionRefused: 'PARCEL_TRANSITION_REFUSED',
|
|
@@ -2194,6 +2195,46 @@ sont validés ensemble ou pas du tout. `eventStoreUnitOfWorkContract` de `@ddd-t
|
|
|
2194
2195
|
prouve pour chaque store transactionnel : rien n'est publié pour un ajout annulé ou refusé par un
|
|
2195
2196
|
conflit de concurrence.
|
|
2196
2197
|
|
|
2198
|
+
## Données personnelles
|
|
2199
|
+
|
|
2200
|
+
Le droit à l'effacement, d'accès et à la portabilité, pour ce qu'un contexte garde d'une personne
|
|
2201
|
+
en clair : ses lignes. Ce qu'un événement stocké scelle est effacé par la clé de sa personne
|
|
2202
|
+
concernée (voir « Event sourcing ») ; ce qu'une table garde en clair est déclaré une fois, à côté
|
|
2203
|
+
du *mapper*, puis effacé, exporté et inventorié à partir de cette déclaration.
|
|
2204
|
+
|
|
2205
|
+
```ts
|
|
2206
|
+
// infrastructure/persistence/person.personal-fields.ts
|
|
2207
|
+
export const personPersonalFields = personalFields<PersonRow>(PERSONS, {
|
|
2208
|
+
subject: 'id', // la colonne qui nomme la personne concernée : un identifiant opaque, jamais une donnée personnelle
|
|
2209
|
+
fields: ['display_name', 'email'],
|
|
2210
|
+
erasure: 'row', // ou 'pseudonymise' : les lignes restent, chaque champ texte lit ERASED_PERSONAL_DATA
|
|
2211
|
+
});
|
|
2212
|
+
```
|
|
2213
|
+
|
|
2214
|
+
| Pièce | Ce qu'elle fait |
|
|
2215
|
+
|---|---|
|
|
2216
|
+
| `personalFields(table, { subject, fields, erasure, files?, retention? })` | La déclaration : quelles colonnes d'une table sont personnelles, à qui elles appartiennent, et comment les lignes d'une personne sont effacées (`row`, supprimées ; `pseudonymise`, chaque champ texte lit `ERASED_PERSONAL_DATA` et tout autre champ rien). `files` nomme les colonnes qui tiennent la clé d'un fichier de la personne : le fichier est supprimé du `FileStorage` et la colonne vidée, quel que soit le mode. Refusé (`InvalidPersonalFieldsError`) : aucun champ, une colonne listée deux fois, une colonne sujet déclarée personnelle |
|
|
2217
|
+
| `PersonalDataErasure` | Le port qu'un contexte étend et nomme, comme il étend `Repository` : `export abstract class PatientErasure extends PersonalDataErasure {}`. `name` est la copie qu'il atteint, telle que le rapport la nomme ; `erase(subject)` efface ce que le contexte garde de la personne dans le *tenant* du travail et répond combien de lignes il a atteintes, aucune la seconde fois. Les *packages* de persistance l'implémentent à partir des déclarations ; `InMemoryPersonalData` ici |
|
|
2218
|
+
| `PersonalDataExport` | Le port du droit d'accès et de la portabilité, étendu et nommé par le contexte comme l'effacement : `exportOf(subject)` répond un `PersonalDataRecord` par ligne sur la personne dans le *tenant* du travail, `{ source, values }`, la source `<name>.<table>`, chaque colonne personnelle et chaque colonne de fichier (par sa clé) en données simples (`PersonalDataValue` : un scalaire tel quel, un instant en texte ISO, `null` pour rien, du texte JSON pour tout le reste), aucune autre colonne et rien de personne d'autre. Les paquets de persistance l'implémentent depuis les déclarations (`KnexPersonalDataExport`, `DrizzlePersonalDataExport`, `PrismaPersonalDataExport`, `TypeOrmPersonalDataExport`) ; `InMemoryPersonalData` ici |
|
|
2219
|
+
| `eraseDataSubject(subject, { keys?, copies, inEveryTenant, rebuilds, isKnown })` | L'effacement entier, dans l'ordre : la clé de la personne détruite (`SubjectKeyStore.erase`, enveloppé par `auditedSubjectKeys` de `@ddd-ts-kit/audit` pour qu'une entrée datée le prouve ; sans `keys`, rien n'est scellé et seules les copies sont effacées, comme dans un projet dont les agrégats sont des lignes), chaque copie effacée dans chaque *tenant*, chaque projection alimentée par le store reconstruite. Une copie qui échoue n'arrête pas les autres ; le premier échec est levé une fois que tout a tourné, et relancer l'effacement l'achève. Un sujet qui n'est pas un identifiant opaque (`isDataSubjectId`, la grammaire d'un id de *tenant*) est refusé avant qu'une clé ne soit touchée (`NotADataSubjectIdError`) ; un id qui n'a détruit aucune clé, rien effacé et qu'`isKnown` ne connaît pas est refusé avant les reconstructions (`UnknownDataSubjectError`) : une faute de frappe, ou un effacement déjà complet. Répond `{ erased, copies, rebuilt }` : si une clé a été détruite, les lignes atteintes par chaque copie, les événements rejoués par chaque projection |
|
|
2220
|
+
| `inEachTenant(scope, tenants)` | Ce qu'on donne à `inEveryTenant` : exécute une copie une fois par *tenant*, dans le contexte du travail doté de ce *tenant*, et somme les lignes. Une écriture de données de *tenant* est confinée au *tenant* de son contexte et jamais élargie par une élévation : c'est le seul moyen d'effacer dans chaque *tenant* |
|
|
2221
|
+
| `exportDataSubject(subject, { exports, inEveryTenant, clock, isKnown })` | Le droit d'accès et la portabilité (RGPD, articles 15 et 20) : chaque export, dans l'ordre listé, dans chaque *tenant*, rassemblé en un `PersonalDataExportDocument` : `format` (`PERSONAL_DATA_EXPORT_FORMAT`, `ddd-ts-kit/personal-data-export@1`, pour qu'un lecteur connaisse la forme et distingue une forme ultérieure), `subject` (l'id opaque, jamais un nom), `exportedAt` (de l'horloge : ce que le document affirme est vrai de cet instant), `records`. Écrit en JSON, c'est la forme structurée, couramment utilisée et lisible par machine que demande l'article 20. Un export qui échoue arrête le rassemblement, puisqu'un document auquel un contexte manquerait en silence affirmerait moins que ce que le système garde ; un sujet qui n'est pas un identifiant opaque est refusé avant toute lecture (`NotADataSubjectIdError` : un export cherche une personne par son id, jamais par un nom ou un email, ce qui serait une recherche dans des données personnelles) ; un id qui ne répond aucun enregistrement et qu'`isKnown` ne connaît pas est refusé (`UnknownDataSubjectError`) plutôt que de recevoir un document vide qui affirmerait que rien n'est gardé. Donnez-lui les exports enveloppés par `auditedPersonalDataExport` de `@ddd-ts-kit/audit`, pour que chaque remise laisse une entrée datée disant qui a lu quoi de qui, jamais les valeurs |
|
|
2222
|
+
| `retention: { after, days \| months \| years }` | Combien de temps les lignes gardent la personne (RGPD, article 5(1)(e)), compté depuis une colonne de date de la ligne qui n'est pas une donnée personnelle et date la fin de la relation (`ended_at`), jamais son début : comptée depuis une inscription, la purge effacerait des personnes encore clientes ; une unité, un nombre entier positif de celle-ci (refusé sinon, `InvalidPersonalFieldsError`). Au-delà, la purge efface la ligne comme `erasure` le dit ; une ligne dont la date est vide n'expire jamais. `expiredBefore(period, now)` donne l'instant, en unités de calendrier de l'UTC |
|
|
2223
|
+
| `PersonalDataRetention`, `purgeExpiredPersonalData(now, retentions)`, `isPersonalDataRetention` | La limitation de la conservation : le port `purgeExpired(now)` répond les lignes qu'une copie a effacées, dans le *tenant* du travail ou dans chaque *tenant* quand le travail n'en nomme aucun ; les adaptateurs d'effacement des quatre paquets de persistance et `InMemoryPersonalData` l'implémentent depuis les mêmes déclarations. `purgeExpiredPersonalData` lance chaque copie au même instant, une copie qui échoue n'arrêtant pas les autres, et répond `{ purged }` par copie ; `isPersonalDataRetention` distingue une copie qui purge d'une copie qui ne fait qu'effacer. Un projet généré la lance chaque nuit (`privacy.purge-expired`) et à la main (`privacy:purge`) |
|
|
2224
|
+
| `dataSubjectErasedV1` | L'annonce d'un effacement, `privacy.data-subject.erased` version 1, `{ subjectId, erasedAt }` : l'id de la personne seul, aucun opérateur (le journal d'audit garde qui a demandé, l'id de corrélation de l'événement y mène), un nom refusé à `create` (`InvalidDataSubjectErasedError`). Il vit ici parce que la couche application de chaque contexte le traite, et il a la forme d'une définition de `@ddd-ts-kit/events`, pour que son registre, son catalogue, AsyncAPI, `on` et `consume` le prennent ; `@IntegrationEventHandler(dataSubjectErasedV1, { consumer })` déclare un *handler*. Un projet généré le publie par l'outbox à la fin de `privacy:erase` |
|
|
2225
|
+
| `recordsInEachTenant(scope, tenants)`, `eachTenant(scope, tenants, work)` | Ce qu'on donne à l'`inEveryTenant` d'un export : exécute un export une fois par *tenant* et rassemble les enregistrements dans l'ordre des *tenants*, comme `inEachTenant` somme les lignes d'un effacement ; les deux sur `eachTenant`, qui exécute le travail une fois par *tenant*, dans le contexte du travail doté de ce *tenant*, et répond chaque résultat |
|
|
2226
|
+
| `InMemoryPersonalData(name, declaration, { files? })` | L'implémentation de référence des deux ports sur une déclaration, les lignes gardées en mémoire (`insert`, `all`) : le *fake* d'un contexte, et ce à quoi `personalDataErasureContract` et `personalDataExportContract` de `@ddd-ts-kit/testing` tiennent chaque adaptateur |
|
|
2227
|
+
| `pseudonymisedValueOf(sqlType)` | Ce que lit une colonne pseudonymisée, d'après son type SQL : `ERASED_PERSONAL_DATA` pour un texte (`text`, `varchar`, `char`, `citext`), rien pour tout autre type. La règle unique que suivent les adaptateurs des quatre *packages* de persistance (`KnexPersonalDataErasure`, `DrizzlePersonalDataErasure`, `PrismaPersonalDataErasure`, `TypeOrmPersonalDataErasure`), pour qu'une déclaration efface de la même façon sur chaque ORM. `NotNullablePersonalColumnError` est ce qu'ils lèvent, avant qu'un fichier ou une ligne ne soit touché, pour une colonne qui ne lirait rien et n'accepte pas null |
|
|
2228
|
+
|
|
2229
|
+
Ce que cela n'atteint pas : un événement d'intégration publié avant l'effacement et ce qui l'a
|
|
2230
|
+
consommé, les sauvegardes jusqu'à leur expiration, et le journal d'audit, qui nomme une personne
|
|
2231
|
+
par un identifiant opaque et jamais par un nom. Dites-le là où l'effacement est offert. L'exemple
|
|
2232
|
+
scheduling exécute cette chaîne (`npm run privacy:erase`) sur le `PersonalDataErasure` de chacun
|
|
2233
|
+
de ses contextes, le réseau de chaque copie atteint comme un *tenant*, et
|
|
2234
|
+
[docs/concepts/personal-data.fr.md](../../docs/concepts/personal-data.fr.md) dit ce qu'un projet
|
|
2235
|
+
généré contient : les adaptateurs de chaque *package* de persistance, le dossier de plateforme
|
|
2236
|
+
qu'`init` écrit, le registre et les règles.
|
|
2237
|
+
|
|
2197
2238
|
## Comment étendre
|
|
2198
2239
|
|
|
2199
2240
|
`Session`, `ExecutionContext`, `Actor`, `AuditEntry` et `ErrorReport` ont chacun une interface
|
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ starts, so a business rule never changes with a library.
|
|
|
42
42
|
| Files | `FileStorage`, `StoredFile`, `FileScanner`, `FileKeys`, `TenantFileKeys`, `FileStaging`, `FileUpload`, `fileUploadsMiddleware`, `FileInspection`, `FileError`, `InMemoryFileStorage`, `LocalFileStorage`, `PurgeStagedFiles` (see "FileStorage, StoredFile, FileScanner") |
|
|
43
43
|
| Tenancy | `tenantScopeOf`, `tenantReachOf`, `acrossTenants`, `tenantKey`, `tenantCacheKey`, `isTenantId`, `TenantDirectory`, `InMemoryTenantDirectory` (see "Tenancy") |
|
|
44
44
|
| Event sourcing | `EventSourcedAggregate`, `EventStore`, `defineStoredEvent`, `EventSerializer`, `EventSourcedRepository`, `SnapshotPolicy`, `personalData`, `PersonalDataCipher`, `CatchUpSubscription`, `EventStoreProjectionRebuild`, `InMemoryEventStore`, `PostgresEventStore` (see "Event sourcing") |
|
|
45
|
+
| Personal data | `personalFields`, `PersonalDataErasure`, `PersonalDataExport`, `eraseDataSubject`, `exportDataSubject`, `PersonalDataExportDocument`, `inEachTenant`, `recordsInEachTenant`, `isDataSubjectId`, `PersonalDataRecord`, `InMemoryPersonalData` (see "Personal data") |
|
|
45
46
|
| Read side | `Criteria`, `defineCriteria`, `validateCriteria`, `scoped`, `planCriteria`, `evaluateCriteria`, `pageOfPlan`, `hydrate`, `ReadModelStore`, `stampOf`, `TableReadModelStore`, `ProjectionRebuild`, `InMemoryReadModelStore` (see "Criteria", "Hydration" and "Projections") |
|
|
46
47
|
| Persistence helpers | `optimisticUpdate`, `expectVersion` (the version a caller read, `If-Match` over HTTP, still the current one, else `PreconditionFailedError`: 412), `schemaNameOf`, `stampCreation`, `stampUpdate`, `tenantScopeOf`, `encodeCursor`, `decodeCursor` |
|
|
47
48
|
| Error reporting | `ErrorReporter`, `ErrorReport`, `errorReportOf`, `reportOnce`, `isUnexpectedError`, `errorReportingMiddleware`, `DeadLetterReports`, `reportProcessFailures`, `NoopErrorReporter` |
|
|
@@ -59,7 +60,7 @@ file, and `ddd-ts-kit generate` writes them):
|
|
|
59
60
|
```ts
|
|
60
61
|
import { AggregateRoot, DomainRefusal, Entity, ValueObject, NamedDomainEvent } from '@ddd-ts-kit/kernel';
|
|
61
62
|
|
|
62
|
-
// The codes of the context, in
|
|
63
|
+
// The codes of the context, in <context>.codes.ts, and its refusals, one class each (see "Domain errors").
|
|
63
64
|
export const OrderingCodes = {
|
|
64
65
|
InvalidQuantity: 'INVALID_QUANTITY',
|
|
65
66
|
OrderAlreadyPlaced: 'ORDER_ALREADY_PLACED',
|
|
@@ -206,7 +207,7 @@ refusal instead of throwing it (`"stack.valueObjects": "result"`). Why each bloc
|
|
|
206
207
|
A business refusal is a `DomainError`: an answer the code planned for, known everywhere by its
|
|
207
208
|
`code`. A context has one class per refusal, named after what is refused, which extends
|
|
208
209
|
`DomainRefusal`; its static factories are named after what the refusal is about, and the code
|
|
209
|
-
of every refusal of the context is written once, in the closed list
|
|
210
|
+
of every refusal of the context is written once, in the closed list `<context>.codes.ts`:
|
|
210
211
|
|
|
211
212
|
<!-- checked sample -->
|
|
212
213
|
```ts
|
|
@@ -215,7 +216,7 @@ import { DomainRefusal } from '@ddd-ts-kit/kernel';
|
|
|
215
216
|
declare const calendar: { readonly id: string };
|
|
216
217
|
declare const slot: { readonly startsAt: Date };
|
|
217
218
|
|
|
218
|
-
//
|
|
219
|
+
// scheduling.codes.ts
|
|
219
220
|
export const SchedulingCodes = {
|
|
220
221
|
SlotTaken: 'SLOT_TAKEN',
|
|
221
222
|
UnknownAppointment: 'APPOINTMENT_NOT_FOUND',
|
|
@@ -356,7 +357,7 @@ import { AggregateRoot, DomainRefusal, defineStateMachine } from '@ddd-ts-kit/ke
|
|
|
356
357
|
export const ParcelStatus = { Registered: 'registered', Shipped: 'shipped', Delivered: 'delivered' } as const;
|
|
357
358
|
export type ParcelStatus = (typeof ParcelStatus)[keyof typeof ParcelStatus];
|
|
358
359
|
|
|
359
|
-
//
|
|
360
|
+
// shipping.codes.ts, then one class per refusal
|
|
360
361
|
export const ShippingCodes = {
|
|
361
362
|
ParcelUnpaid: 'PARCEL_UNPAID',
|
|
362
363
|
ParcelTransitionRefused: 'PARCEL_TRANSITION_REFUSED',
|
|
@@ -2106,6 +2107,46 @@ writes the outbox: the stream and the outbox records commit together or not at a
|
|
|
2106
2107
|
`eventStoreUnitOfWorkContract` of `@ddd-ts-kit/testing` proves it for each transactional store:
|
|
2107
2108
|
nothing is published for an append rolled back or refused by a concurrency conflict.
|
|
2108
2109
|
|
|
2110
|
+
## Personal data
|
|
2111
|
+
|
|
2112
|
+
The right to erasure, of access and to portability, for what a context keeps of a person in
|
|
2113
|
+
clear: its rows. What a stored event seals is erased by the key of its data subject (see "Event
|
|
2114
|
+
sourcing"); what a table holds in clear is declared once, next to the mapper, and erased,
|
|
2115
|
+
exported and inventoried from that declaration.
|
|
2116
|
+
|
|
2117
|
+
```ts
|
|
2118
|
+
// infrastructure/persistence/person.personal-fields.ts
|
|
2119
|
+
export const personPersonalFields = personalFields<PersonRow>(PERSONS, {
|
|
2120
|
+
subject: 'id', // the column that names the data subject: an opaque identifier, never personal data itself
|
|
2121
|
+
fields: ['display_name', 'email'],
|
|
2122
|
+
erasure: 'row', // or 'pseudonymise': the rows stay, each text field reads ERASED_PERSONAL_DATA
|
|
2123
|
+
});
|
|
2124
|
+
```
|
|
2125
|
+
|
|
2126
|
+
| Piece | What it does |
|
|
2127
|
+
|---|---|
|
|
2128
|
+
| `personalFields(table, { subject, fields, erasure, files?, retention? })` | The declaration: which columns of a table are personal, whose they are, and how the rows of a subject are erased (`row`, deleted; `pseudonymise`, each text field reads `ERASED_PERSONAL_DATA` and any other field nothing). `files` names the columns that hold the key of a file of the subject: the file is deleted from the `FileStorage` and the column emptied, whatever the mode. Refused (`InvalidPersonalFieldsError`): no field, a column listed twice, a subject column declared personal |
|
|
2129
|
+
| `PersonalDataErasure` | The port a context extends and names, as it extends `Repository`: `export abstract class PatientErasure extends PersonalDataErasure {}`. `name` is the copy it reaches, as the report names it; `erase(subject)` erases what the context holds of the subject in the tenant of the work and answers how many rows it reached, none the second time. The persistence packages implement it from the declarations; `InMemoryPersonalData` here |
|
|
2130
|
+
| `PersonalDataExport` | The port of the right of access and to portability, extended and named by the context as the erasure is: `exportOf(subject)` answers one `PersonalDataRecord` per row about the subject in the tenant of the work, `{ source, values }`, the source `<name>.<table>`, each personal column and each file column (by its key) as plain data (`PersonalDataValue`: a scalar as it is, an instant as ISO text, `null` for nothing, JSON text for anything else), no other column and nothing of anyone else. The persistence packages implement it from the declarations (`KnexPersonalDataExport`, `DrizzlePersonalDataExport`, `PrismaPersonalDataExport`, `TypeOrmPersonalDataExport`); `InMemoryPersonalData` here |
|
|
2131
|
+
| `eraseDataSubject(subject, { keys?, copies, inEveryTenant, rebuilds, isKnown })` | The whole erasure, in order: the key of the subject destroyed (`SubjectKeyStore.erase`, wrapped by `auditedSubjectKeys` of `@ddd-ts-kit/audit` so that a dated entry proves it; `keys` left out, nothing is sealed and the copies alone are erased, as in a project whose aggregates are rows), every copy erased in every tenant, every projection fed by the store rebuilt. A copy that fails does not stop the others; the first failure is thrown once everything ran, and running the erasure again completes it. A subject that is not an opaque identifier (`isDataSubjectId`, the grammar of a tenant id) is refused before any key is touched (`NotADataSubjectIdError`); an id that destroyed no key, erased nothing and that `isKnown` denies is refused before the rebuilds (`UnknownDataSubjectError`): a mistyped id, or an erasure already complete. Answers `{ erased, copies, rebuilt }`: whether a key was destroyed, the rows each copy reached, the events each projection replayed |
|
|
2132
|
+
| `inEachTenant(scope, tenants)` | What `inEveryTenant` is given: runs a copy once per tenant, in the context of the work given that tenant, and sums the rows. A write of tenant data is confined to the tenant of its context and never widened by an elevation, so this is the one way to erase in every tenant |
|
|
2133
|
+
| `exportDataSubject(subject, { exports, inEveryTenant, clock, isKnown })` | The right of access and to portability (GDPR articles 15 and 20): every export, in the order listed, in every tenant, gathered into one `PersonalDataExportDocument`: `format` (`PERSONAL_DATA_EXPORT_FORMAT`, `ddd-ts-kit/personal-data-export@1`, so that a reader knows the shape and a later one is told apart), `subject` (the opaque id, never a name), `exportedAt` (from the clock: what the document states is true of that instant), `records`. Written as JSON, it is the structured, commonly used and machine-readable form article 20 asks for. An export that fails stops the gathering, since a document that silently lacked a context would state less than the system keeps; a subject that is not an opaque identifier is refused before anything is read (`NotADataSubjectIdError`: an export looks a person up by id, never by a name or an email, which would be a search in personal data); an id that answers no record and that `isKnown` denies is refused (`UnknownDataSubjectError`) rather than answered with an empty document that would state nothing is kept. Give it the exports wrapped by `auditedPersonalDataExport` of `@ddd-ts-kit/audit`, so that each handover leaves a dated entry naming who read what of whom, never the values |
|
|
2134
|
+
| `retention: { after, days \| months \| years }` | How long the rows keep the person (GDPR article 5(1)(e)), counted from a date column of the row that is not personal data and dates the end of the relation (`ended_at`), never its beginning: counted from a registration, the purge would erase people who are still customers; one unit, a positive whole number of it (refused otherwise, `InvalidPersonalFieldsError`). Past that, the purge erases the row as `erasure` says; a row whose date is empty never expires. `expiredBefore(period, now)` gives the instant, in calendar units of UTC |
|
|
2135
|
+
| `PersonalDataRetention`, `purgeExpiredPersonalData(now, retentions)`, `isPersonalDataRetention` | The storage limitation: the port `purgeExpired(now)` answers the rows a copy erased, in the tenant of the work or in every tenant when the work names none; the erasure adapters of the four persistence packages and `InMemoryPersonalData` implement it from the same declarations. `purgeExpiredPersonalData` runs every copy at one instant, a failing one not stopping the others, and answers `{ purged }` by copy; `isPersonalDataRetention` tells a copy that purges from one that only erases. A generated project runs it every night (`privacy.purge-expired`) and by hand (`privacy:purge`) |
|
|
2136
|
+
| `dataSubjectErasedV1` | The announcement of an erasure, `privacy.data-subject.erased` version 1, `{ subjectId, erasedAt }`: the id of the person alone, no operator (the audit trail keeps who asked, the correlation id of the event leads to it), a name refused at `create` (`InvalidDataSubjectErasedError`). It lives here because the application layer of every context handles it, and it is shaped as a definition of `@ddd-ts-kit/events`, so that its registry, catalog, AsyncAPI, `on` and `consume` take it; `@IntegrationEventHandler(dataSubjectErasedV1, { consumer })` declares a handler. A generated project publishes it through the outbox at the end of `privacy:erase` |
|
|
2137
|
+
| `recordsInEachTenant(scope, tenants)`, `eachTenant(scope, tenants, work)` | What `inEveryTenant` of an export is given: runs an export once per tenant and gathers the records in the order of the tenants, as `inEachTenant` sums the rows of an erasure; both over `eachTenant`, which runs the work once per tenant, in the context of the work given that tenant, and answers each result |
|
|
2138
|
+
| `InMemoryPersonalData(name, declaration, { files? })` | The reference implementation of both ports over one declaration, the rows held in memory (`insert`, `all`): the fake of a context, and what `personalDataErasureContract` and `personalDataExportContract` of `@ddd-ts-kit/testing` hold every adapter to |
|
|
2139
|
+
| `pseudonymisedValueOf(sqlType)` | What a pseudonymised column reads, from its SQL type: `ERASED_PERSONAL_DATA` for a text (`text`, `varchar`, `char`, `citext`), nothing for any other type. The one rule the adapters of the four persistence packages follow (`KnexPersonalDataErasure`, `DrizzlePersonalDataErasure`, `PrismaPersonalDataErasure`, `TypeOrmPersonalDataErasure`), so that one declaration erases the same way on every ORM. `NotNullablePersonalColumnError` is what they throw, before any file or row is touched, for a column that would read nothing and does not accept null |
|
|
2140
|
+
|
|
2141
|
+
What it does not reach: an integration event published before the erasure and whatever consumed
|
|
2142
|
+
it, the backups until they expire, and the audit trail, which names a person by an opaque id and
|
|
2143
|
+
never by a name. Say so where the erasure is offered. The scheduling example runs this chain
|
|
2144
|
+
(`npm run privacy:erase`) over the `PersonalDataErasure` of each of its contexts, the network of
|
|
2145
|
+
each copy reached as a tenant, and
|
|
2146
|
+
[docs/concepts/personal-data.md](../../docs/concepts/personal-data.md) says what a generated
|
|
2147
|
+
project holds: the adapters of each persistence package, the platform folder `init` writes, the
|
|
2148
|
+
register and the rules.
|
|
2149
|
+
|
|
2109
2150
|
## How to extend
|
|
2110
2151
|
|
|
2111
2152
|
`Session`, `ExecutionContext`, `Actor`, `AuditEntry` and `ErrorReport` each have an empty interface that a project fills by
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Retention } from './retention.js';
|
|
2
|
+
/** One unit, a positive whole number of it, counted from a column that is not personal data. */
|
|
3
|
+
export declare function assertRetention<Row>(retention: Retention<Row>, personal: readonly string[]): void;
|
|
4
|
+
//# sourceMappingURL=assert-retention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-retention.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/assert-retention.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAcjG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InvalidPersonalFieldsError } from './invalid-personal-fields-error.js';
|
|
2
|
+
/** One unit, a positive whole number of it, counted from a column that is not personal data. */
|
|
3
|
+
export function assertRetention(retention, personal) {
|
|
4
|
+
const units = [retention.days, retention.months, retention.years].filter((unit) => unit !== undefined);
|
|
5
|
+
if (units.length !== 1 || !units.every((unit) => Number.isInteger(unit) && unit > 0)) {
|
|
6
|
+
throw new InvalidPersonalFieldsError('gives its retention as one unit, days, months or years, a positive whole number of it');
|
|
7
|
+
}
|
|
8
|
+
if (personal.includes(retention.after)) {
|
|
9
|
+
throw new InvalidPersonalFieldsError(`counts its retention from "${retention.after}", which it declares personal: a retention runs from a fact of the row, an end or a last activity`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=assert-retention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-retention.js","sourceRoot":"","sources":["../../../src/application/personal-data/assert-retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAG7E,gGAAgG;AAChG,MAAM,UAAU,eAAe,CAAM,SAAyB,EAAE,QAA2B;IACzF,MAAM,KAAK,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAEvG,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;QACrF,MAAM,IAAI,0BAA0B,CAClC,uFAAuF,CACxF,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,0BAA0B,CAClC,8BAA8B,SAAS,CAAC,KAAK,mGAAmG,CACjJ,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IntegrationEvent } from '../events/integration-event.js';
|
|
2
|
+
import type { Result } from '../../domain/result/result.js';
|
|
3
|
+
import type { DataSubjectErasedParseError } from './data-subject-erased-parse-error.js';
|
|
4
|
+
import type { DataSubjectErasedPayload } from './data-subject-erased-payload.js';
|
|
5
|
+
import type { PayloadIssue } from './payload-issue.js';
|
|
6
|
+
/**
|
|
7
|
+
* The declaration of `privacy.data-subject.erased`, shaped as a definition of `@ddd-ts-kit/events`
|
|
8
|
+
* is, so that its registry, its catalog, AsyncAPI, `on` and `consume` take it as they take any
|
|
9
|
+
* other, and `@IntegrationEventHandler` and the container read it like the published language of a
|
|
10
|
+
* context. It lives in the kernel because the application layer of every context handles it.
|
|
11
|
+
*/
|
|
12
|
+
export interface DataSubjectErasedDefinition {
|
|
13
|
+
readonly type: 'privacy.data-subject.erased';
|
|
14
|
+
readonly version: 1;
|
|
15
|
+
readonly producer: 'privacy';
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly deprecated: false;
|
|
18
|
+
readonly payload: {
|
|
19
|
+
parse(input: unknown): Result<DataSubjectErasedPayload, PayloadIssue[]>;
|
|
20
|
+
toJsonSchema(): Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
/** Producer side: throws `InvalidDataSubjectErasedError` on an invalid payload, a name instead of an id first of all. */
|
|
23
|
+
create(payload: DataSubjectErasedPayload, meta: {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly occurredAt: Date | string;
|
|
26
|
+
readonly correlationId?: string;
|
|
27
|
+
readonly traceparent?: string;
|
|
28
|
+
}): IntegrationEvent<DataSubjectErasedPayload>;
|
|
29
|
+
/** Consumer side: checks type, version and payload, and never throws. */
|
|
30
|
+
parse(event: IntegrationEvent): Result<IntegrationEvent<DataSubjectErasedPayload>, DataSubjectErasedParseError>;
|
|
31
|
+
is(event: IntegrationEvent): event is IntegrationEvent<DataSubjectErasedPayload>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=data-subject-erased-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erased-definition.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erased-definition.ts"],"names":[],"mappings":"AAAA,OAA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,KAAK,IAAI,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;CAClF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erased-definition.js","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erased-definition.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PayloadIssue } from './payload-issue.js';
|
|
2
|
+
/** Why an event is not an erasure of version 1: the shape `@ddd-ts-kit/events` reports for any definition. */
|
|
3
|
+
export type DataSubjectErasedParseError = {
|
|
4
|
+
readonly reason: 'type-mismatch';
|
|
5
|
+
readonly expected: string;
|
|
6
|
+
readonly actual: string;
|
|
7
|
+
} | {
|
|
8
|
+
readonly reason: 'version-mismatch';
|
|
9
|
+
readonly expected: number;
|
|
10
|
+
readonly actual: number;
|
|
11
|
+
} | {
|
|
12
|
+
readonly reason: 'invalid-payload';
|
|
13
|
+
readonly issues: readonly PayloadIssue[];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=data-subject-erased-parse-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erased-parse-error.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erased-parse-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,8GAA8G;AAC9G,MAAM,MAAM,2BAA2B,GACnC;IAAE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACxF;IAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3F;IAAE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erased-parse-error.js","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erased-parse-error.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `privacy.data-subject.erased` says: whose data was erased, and when. The opaque id of the
|
|
3
|
+
* person alone: who asked is not repeated to every consumer and kept as long as the broker keeps
|
|
4
|
+
* its messages, the audit trail records it, and the correlation id of the event leads to its entry.
|
|
5
|
+
*/
|
|
6
|
+
export interface DataSubjectErasedPayload {
|
|
7
|
+
/** The opaque identifier of the data subject, as the request named it. */
|
|
8
|
+
readonly subjectId: string;
|
|
9
|
+
/** When the platform erased what it keeps of the person, as ISO text. */
|
|
10
|
+
readonly erasedAt: string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=data-subject-erased-payload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erased-payload.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erased-payload.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erased-payload.js","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erased-payload.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DataSubjectErasedDefinition } from './data-subject-erased-definition.js';
|
|
2
|
+
/**
|
|
3
|
+
* The erasure of a data subject, published by the platform through the outbox once every copy it
|
|
4
|
+
* reaches is erased (GDPR articles 17 and 19): a context that runs as a service of its own, or a
|
|
5
|
+
* system that copied personal data from an integration event, erases its copy on its side, with
|
|
6
|
+
* the handler `generate erasure-handler <context>` writes. The payload names the person by the
|
|
7
|
+
* opaque id alone, and no operator: the event erases nothing by itself and carries nothing to erase,
|
|
8
|
+
* and who asked stays in the audit trail, which its correlation id leads to. A copy already
|
|
9
|
+
* gone (a message in a dead letter queue, a topic) is bounded by the retention of the broker, as a
|
|
10
|
+
* backup is by its own.
|
|
11
|
+
*/
|
|
12
|
+
export declare const dataSubjectErasedV1: DataSubjectErasedDefinition;
|
|
13
|
+
//# sourceMappingURL=data-subject-erased-v1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erased-v1.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erased-v1.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAUpF;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,2BA8BjC,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { err } from '../../domain/result/err.js';
|
|
2
|
+
import { ok } from '../../domain/result/ok.js';
|
|
3
|
+
import { InvalidDataSubjectErasedError } from './invalid-data-subject-erased-error.js';
|
|
4
|
+
import { isDataSubjectId } from './is-data-subject-id.js';
|
|
5
|
+
const TYPE = 'privacy.data-subject.erased';
|
|
6
|
+
const VERSION = 1;
|
|
7
|
+
/**
|
|
8
|
+
* The erasure of a data subject, published by the platform through the outbox once every copy it
|
|
9
|
+
* reaches is erased (GDPR articles 17 and 19): a context that runs as a service of its own, or a
|
|
10
|
+
* system that copied personal data from an integration event, erases its copy on its side, with
|
|
11
|
+
* the handler `generate erasure-handler <context>` writes. The payload names the person by the
|
|
12
|
+
* opaque id alone, and no operator: the event erases nothing by itself and carries nothing to erase,
|
|
13
|
+
* and who asked stays in the audit trail, which its correlation id leads to. A copy already
|
|
14
|
+
* gone (a message in a dead letter queue, a topic) is bounded by the retention of the broker, as a
|
|
15
|
+
* backup is by its own.
|
|
16
|
+
*/
|
|
17
|
+
export const dataSubjectErasedV1 = {
|
|
18
|
+
type: TYPE,
|
|
19
|
+
version: VERSION,
|
|
20
|
+
producer: 'privacy',
|
|
21
|
+
description: 'Every copy the platform reaches of a data subject is erased: erase yours.',
|
|
22
|
+
deprecated: false,
|
|
23
|
+
payload: { parse: parsePayload, toJsonSchema: jsonSchema },
|
|
24
|
+
create(payload, meta) {
|
|
25
|
+
const parsed = parsePayload(payload);
|
|
26
|
+
if (!parsed.ok) {
|
|
27
|
+
throw new InvalidDataSubjectErasedError(parsed.error);
|
|
28
|
+
}
|
|
29
|
+
const occurredAt = typeof meta.occurredAt === 'string' ? meta.occurredAt : meta.occurredAt.toISOString();
|
|
30
|
+
return {
|
|
31
|
+
id: meta.id,
|
|
32
|
+
type: TYPE,
|
|
33
|
+
version: VERSION,
|
|
34
|
+
occurredAt,
|
|
35
|
+
payload: parsed.value,
|
|
36
|
+
...(meta.traceparent === undefined ? {} : { traceparent: meta.traceparent }),
|
|
37
|
+
...(meta.correlationId === undefined ? {} : { correlationId: meta.correlationId }),
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
parse: parseEvent,
|
|
41
|
+
is(event) {
|
|
42
|
+
return event.type === TYPE && event.version === VERSION;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
function parseEvent(event) {
|
|
46
|
+
if (event.type !== TYPE) {
|
|
47
|
+
return err({ reason: 'type-mismatch', expected: TYPE, actual: event.type });
|
|
48
|
+
}
|
|
49
|
+
if (event.version !== VERSION) {
|
|
50
|
+
return err({ reason: 'version-mismatch', expected: VERSION, actual: event.version });
|
|
51
|
+
}
|
|
52
|
+
const payload = parsePayload(event.payload);
|
|
53
|
+
return payload.ok
|
|
54
|
+
? ok({ ...event, payload: payload.value })
|
|
55
|
+
: err({ reason: 'invalid-payload', issues: payload.error });
|
|
56
|
+
}
|
|
57
|
+
function parsePayload(input) {
|
|
58
|
+
const subjectId = textOf(input, 'subjectId');
|
|
59
|
+
const erasedAt = textOf(input, 'erasedAt');
|
|
60
|
+
const issues = [
|
|
61
|
+
...(isDataSubjectId(subjectId) ? [] : [issue('subjectId', 'is not the opaque identifier of a data subject')]),
|
|
62
|
+
...(erasedAt !== undefined && !Number.isNaN(Date.parse(erasedAt)) ? [] : [issue('erasedAt', 'is not an instant')]),
|
|
63
|
+
];
|
|
64
|
+
if (subjectId === undefined || erasedAt === undefined || issues.length > 0) {
|
|
65
|
+
return err(issues);
|
|
66
|
+
}
|
|
67
|
+
return ok({ subjectId, erasedAt });
|
|
68
|
+
}
|
|
69
|
+
function textOf(input, name) {
|
|
70
|
+
const value = typeof input === 'object' && input !== null ? Reflect.get(input, name) : undefined;
|
|
71
|
+
return typeof value === 'string' ? value : undefined;
|
|
72
|
+
}
|
|
73
|
+
function issue(path, message) {
|
|
74
|
+
return { path, code: 'invalid', message: `${path} ${message}` };
|
|
75
|
+
}
|
|
76
|
+
function jsonSchema() {
|
|
77
|
+
return {
|
|
78
|
+
type: 'object',
|
|
79
|
+
required: ['subjectId', 'erasedAt'],
|
|
80
|
+
additionalProperties: false,
|
|
81
|
+
properties: {
|
|
82
|
+
subjectId: { type: 'string', description: 'The opaque identifier of the data subject.' },
|
|
83
|
+
erasedAt: { type: 'string', format: 'date-time', description: 'When the platform erased its copies.' },
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=data-subject-erased-v1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erased-v1.js","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erased-v1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAK5C,OAAO,EAAE,6BAA6B,EAAE,MA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AAE;SACvG;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** What an erasure did: whether the subject had a key, the rows each copy reached in every tenant, and the events each projection replayed. */
|
|
2
|
+
export interface DataSubjectErasureReport {
|
|
3
|
+
readonly erased: boolean;
|
|
4
|
+
readonly copies: Readonly<Record<string, number>>;
|
|
5
|
+
readonly rebuilt: Readonly<Record<string, number>>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=data-subject-erasure-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erasure-report.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erasure-report.ts"],"names":[],"mappings":"AAAA,+IAA+I;AAC/I,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erasure-report.js","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erasure-report.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SubjectKeyStore } from '../ports/subject-key-store.js';
|
|
2
|
+
import type { PersonalDataCopy } from './personal-data-copy.js';
|
|
3
|
+
import type { ProjectionToRebuild } from './projection-to-rebuild.js';
|
|
4
|
+
/** What an erasure is made of: the keys, the copies the contexts keep, how to reach every tenant, the projections to rebuild. */
|
|
5
|
+
export interface DataSubjectErasure {
|
|
6
|
+
/**
|
|
7
|
+
* The keys the personal values of the stored events are sealed with: the key of the subject is
|
|
8
|
+
* destroyed first. Left out, nothing is sealed, as in a project whose aggregates are rows: the
|
|
9
|
+
* copies alone are erased, and the report says no key was destroyed.
|
|
10
|
+
*/
|
|
11
|
+
readonly keys?: SubjectKeyStore;
|
|
12
|
+
/** The copies the contexts keep of a data subject in clear, erased after the key, in every tenant. None: the key and the rebuilds alone. */
|
|
13
|
+
readonly copies?: readonly PersonalDataCopy[];
|
|
14
|
+
/**
|
|
15
|
+
* Runs a copy once per tenant, in an execution context of that tenant, and sums what it erased:
|
|
16
|
+
* a copy writes tenant data, which no elevation widens (`inEachTenant`). Left out, a copy runs
|
|
17
|
+
* once, in the current context.
|
|
18
|
+
*/
|
|
19
|
+
readonly inEveryTenant?: (work: () => Promise<number>) => Promise<number>;
|
|
20
|
+
/** The projections fed by the event store, rebuilt once the key is gone. None: nothing is rebuilt. */
|
|
21
|
+
readonly rebuilds?: readonly ProjectionToRebuild[];
|
|
22
|
+
/**
|
|
23
|
+
* Whether the subject exists at all, asked only when no key was destroyed and no copy erased:
|
|
24
|
+
* an id that destroys no key, erases nothing and that nobody knows is a mistyped one, refused
|
|
25
|
+
* before the rebuilds; one that somebody knows is a run again. Left out, every id is taken as
|
|
26
|
+
* known. A subject with a key is erased whether anybody still knows it or not: the key comes
|
|
27
|
+
* first, the record after.
|
|
28
|
+
*/
|
|
29
|
+
readonly isKnown?: (subject: string) => Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=data-subject-erasure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erasure.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erasure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,iIAAiI;AACjI,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC;IAChC,4IAA4I;IAC5I,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1E,sGAAsG;IACtG,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACnD;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-erasure.js","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-erasure.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Clock } from '../ports/clock.js';
|
|
2
|
+
import type { PersonalDataExport } from '../ports/personal-data-export.js';
|
|
3
|
+
import type { PersonalDataRecord } from './personal-data-record.js';
|
|
4
|
+
/** What an export is made of: the exports the contexts declare, how to reach every tenant, the clock that dates the document. */
|
|
5
|
+
export interface DataSubjectExport {
|
|
6
|
+
/** The exports the contexts declare, one port per context, each reading its `personalFields` declarations. None: an empty document. */
|
|
7
|
+
readonly exports?: readonly PersonalDataExport[];
|
|
8
|
+
/**
|
|
9
|
+
* Runs an export once per tenant, in an execution context of that tenant, and gathers what it
|
|
10
|
+
* answered: a read of tenant data is confined to the tenant of its context (`recordsInEachTenant`).
|
|
11
|
+
* Left out, an export runs once, in the current context.
|
|
12
|
+
*/
|
|
13
|
+
readonly inEveryTenant?: (work: () => Promise<readonly PersonalDataRecord[]>) => Promise<readonly PersonalDataRecord[]>;
|
|
14
|
+
/** Dates the document: the instant the records were read. */
|
|
15
|
+
readonly clock: Clock;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the subject exists at all, asked only when no context answered a record: an id that
|
|
18
|
+
* nobody knows is a mistyped one, refused rather than answered with an empty document, which
|
|
19
|
+
* would state that nothing is kept of the person. Left out, every id is taken as known.
|
|
20
|
+
*/
|
|
21
|
+
readonly isKnown?: (subject: string) => Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=data-subject-export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-export.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,iIAAiI;AACjI,MAAM,WAAW,iBAAiB;IAChC,uIAAuI;IACvI,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACjD;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,IAAI,EAAE,MAAM,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC,KAC/C,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC,CAAC;IAC5C,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-subject-export.js","sourceRoot":"","sources":["../../../src/application/personal-data/data-subject-export.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExecutionScope } from '../ports/execution-scope.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runs the work once per tenant, in the context of the work in progress given that tenant (same
|
|
4
|
+
* actor, same correlation, same origin), and answers what each run answered, in the order of the
|
|
5
|
+
* tenants. Tenant data is confined to the tenant of its context and never widened by an elevation,
|
|
6
|
+
* so this is the one way to reach every tenant. Needs a context to run in (`scope.require()`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function eachTenant<T>(scope: ExecutionScope, tenants: readonly string[], work: () => Promise<T>): Promise<T[]>;
|
|
9
|
+
//# sourceMappingURL=each-tenant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"each-tenant.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/each-tenant.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,EAAE,CAAC,CASd"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { executionContext } from '../execution/execution-context.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runs the work once per tenant, in the context of the work in progress given that tenant (same
|
|
4
|
+
* actor, same correlation, same origin), and answers what each run answered, in the order of the
|
|
5
|
+
* tenants. Tenant data is confined to the tenant of its context and never widened by an elevation,
|
|
6
|
+
* so this is the one way to reach every tenant. Needs a context to run in (`scope.require()`).
|
|
7
|
+
*/
|
|
8
|
+
export async function eachTenant(scope, tenants, work) {
|
|
9
|
+
const current = scope.require();
|
|
10
|
+
const answers = [];
|
|
11
|
+
for (const tenantId of tenants) {
|
|
12
|
+
answers.push(await scope.run(executionContext({ ...current, tenantId }), work));
|
|
13
|
+
}
|
|
14
|
+
return answers;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=each-tenant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"each-tenant.js","sourceRoot":"","sources":["../../../src/application/personal-data/each-tenant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,KAAqB,EACrB,OAA0B,EAC1B,IAAsB;IAEtB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,OAAO,GAAQ,EAAE,CAAC;IAExB,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|