@ddd-ts-kit/kernel 0.106.0 → 0.108.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  [English](README.md) · **Français**
2
- <!-- translation-of: README.md sha256:69a13e25d984cf10 -->
2
+ <!-- translation-of: README.md sha256:7668980877181ed1 -->
3
3
 
4
4
  # @ddd-ts-kit/kernel
5
5
 
@@ -2214,7 +2214,7 @@ export class AttendanceRecord extends EventSourcedAggregate<AttendanceEvent, Att
2214
2214
  | `defineStoredEvent(Event, spec)` | Comment un événement est stocké : `version` de sa forme, `encode(event): NamedData` (données simples, dates gardées en texte ISO), `decode(data, envelope)` qui lit chaque champ par type (`data.text('x')`, `data.instant('at')`, `data.record('amount')`), et des `upcasters` depuis chaque version antérieure |
2215
2215
  | `EventSerializer<E>` | Chaque événement stocké d'un agrégat (`StoredEventTypes<E>` : une entrée par événement, sinon cela ne compile pas). Un événement stocké n'est jamais réécrit : il passe par un *upcaster* à la lecture. Un événement d'une forme plus récente que ce que connaît la version publiée, ou une version sans *upcaster*, est une `UnreadableEventError` |
2216
2216
  | `EventSourcedRepository` | Ce à quoi délègue l'adaptateur de *repository* : `findById` rejoue le flux `<category>-<id>` (depuis le dernier *snapshot*), `save` ajoute dans la transaction de l'unité de travail ; les événements partent ensuite avec l'enregistrement comme n'importe quels autres |
2217
- | `SnapshotPolicy` | Par agrégat : `every` tant d'événements, une `version` de la forme (une autre est ignorée, le flux rejoué), `encode` et `decode`. `expectSnapshotEquivalence` de `@ddd-ts-kit/testing` prouve qu'un *snapshot* reconstruit l'état que donne un rejeu complet |
2217
+ | `SnapshotPolicy` | Par agrégat : `every` tant d'événements, une `version` de la forme (une autre est ignorée, le flux rejoué), `encode`, qui scelle une valeur personnelle avec `personalData` comme dans un événement, et `decode`. `expectSnapshotEquivalence` de `@ddd-ts-kit/testing` prouve qu'un *snapshot* reconstruit l'état que donne un rejeu complet |
2218
2218
  | `personalData(subject, value)` | Marque une valeur personnelle dans `encode`. `PersonalDataCipher` sur un `SubjectKeyStore` la scelle avec la clé de sa personne concernée (AES-256-GCM) ; `SubjectKeyStore.erase(subject)` détruit la clé, et un rejeu lit alors `ERASED_PERSONAL_DATA`. `decode` lit une valeur personnelle avec `data.personalText('x')`, `data.personalInstant('at')` ou `data.personal('email', Email.of)`, qui répondent `undefined` une fois la personne effacée : une valeur qui n'est pas un texte libre ne rend jamais l'agrégat illisible ; `data.isErased('x')` dit si elle l'a été. Le chiffreur ouvre une valeur effacée en `ErasedValue`, `{ $erased: { key } }`, jamais en texte : `data.text` la lit `ERASED_PERSONAL_DATA`, un texte qui se lit `[erased]` n'est pas pris pour elle, et un upcaster voit cette forme |
2219
2219
  | `EventStorePersonalDataExport({ events, keys, name?, scope? })` | Le `PersonalDataExport` de ce que l'event store garde d'une personne : un enregistrement par événement qui porte une valeur scellée avec une clé de la personne, sous `<name>.<type d'événement>` (`event-store` par défaut), qui nomme son `event` (flux, identifiant de l'agrégat, version, instant), chaque valeur ouverte sous son chemin dans les données. Lit tout le store par tours (`batchSize`, 500) dans l'ordre des positions, celui où un store valide ses ajouts, avec un scope les seuls événements du *tenant* du travail ; une valeur dont la clé a été détruite ne répond rien, une qui ne se déchiffre pas est nommée dans `unreadable`. `runExport` d'un projet en `--event-sourcing on` la remet comme `platform.event-store` |
2220
2220
 
@@ -2272,7 +2272,7 @@ export const personPersonalFields = personalFields<PersonRow>(PERSONS, {
2272
2272
  | `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 |
2273
2273
  | `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 |
2274
2274
  | `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 |
2275
- | `eraseDataSubject(subject, { keys?, copies, shared, 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* (chacune enveloppée par `auditedPersonalDataErasure`, dont les entrées prouvent l'effacement avec ou sans clé), `shared`, les copies qu'aucun *tenant* ne confine (l'outbox, le stockage des *jobs*), effacées une fois, 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 |
2275
+ | `eraseDataSubject(subject, { keys?, copies, shared, 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* (chacune enveloppée par `auditedPersonalDataErasure`, dont les entrées prouvent l'effacement avec ou sans clé), `shared`, les copies qu'aucun *tenant* ne confine (l'outbox, le stockage des *jobs*), effacées une fois, chaque projection alimentée par le store reconstruite. Une copie ou une reconstruction 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 |
2276
2276
  | `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* |
2277
2277
  | `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 |
2278
2278
  | `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 |
package/README.md CHANGED
@@ -2125,7 +2125,7 @@ export class AttendanceRecord extends EventSourcedAggregate<AttendanceEvent, Att
2125
2125
  | `defineStoredEvent(Event, spec)` | How one event is stored: `version` of its shape, `encode(event): NamedData` (plain data, dates kept as ISO text), `decode(data, envelope)` reading each field by type (`data.text('x')`, `data.instant('at')`, `data.record('amount')`), and `upcasters` from each older version |
2126
2126
  | `EventSerializer<E>` | Every stored event of one aggregate (`StoredEventTypes<E>`: one entry per event, or it does not compile). A stored event is never rewritten: it is upcast when read. An event of a later shape than the release knows, or a version without upcaster, is an `UnreadableEventError` |
2127
2127
  | `EventSourcedRepository` | What the repository adapter delegates to: `findById` replays the stream `<category>-<id>` (from the last snapshot), `save` appends in the transaction of the unit of work; the events then leave with the save like any other |
2128
- | `SnapshotPolicy` | Per aggregate: `every` so many events, a `version` of the shape (another one is ignored, the stream replayed), `encode` and `decode`. `expectSnapshotEquivalence` of `@ddd-ts-kit/testing` proves a snapshot rebuilds the state a full replay does |
2128
+ | `SnapshotPolicy` | Per aggregate: `every` so many events, a `version` of the shape (another one is ignored, the stream replayed), `encode`, which seals a personal value with `personalData` as in an event, and `decode`. `expectSnapshotEquivalence` of `@ddd-ts-kit/testing` proves a snapshot rebuilds the state a full replay does |
2129
2129
  | `personalData(subject, value)` | Marks a personal value in `encode`. `PersonalDataCipher` over a `SubjectKeyStore` seals it with the key of its data subject (AES-256-GCM); `SubjectKeyStore.erase(subject)` destroys the key, and a replay then reads `ERASED_PERSONAL_DATA`. `decode` reads a personal value with `data.personalText('x')`, `data.personalInstant('at')` or `data.personal('email', Email.of)`, which answer `undefined` once the subject is erased, so a value that is not free text never makes the aggregate unreadable; `data.isErased('x')` says whether it was. The cipher opens an erased value as an `ErasedValue`, `{ $erased: { key } }`, never as a text: `data.text` reads it `ERASED_PERSONAL_DATA`, a text that reads `[erased]` is not taken for one, and an upcaster sees that shape |
2130
2130
  | `EventStorePersonalDataExport({ events, keys, name?, scope? })` | The `PersonalDataExport` of what the event store keeps of a person: one record per event holding a value sealed with a key of the subject, under `<name>.<event type>` (`event-store` by default), naming its `event` (stream, aggregate id, version, instant), each value opened under its path in the data. Reads the whole store in rounds (`batchSize`, 500) in the order of the positions, which a store commits in, with a scope only the events of the tenant of the work; a value whose key was destroyed answers nothing, one that does not decipher is named in `unreadable`. `runExport` of a project with `--event-sourcing on` hands it over as `platform.event-store` |
2131
2131
 
@@ -2182,7 +2182,7 @@ export const personPersonalFields = personalFields<PersonRow>(PERSONS, {
2182
2182
  | `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 |
2183
2183
  | `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 |
2184
2184
  | `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 |
2185
- | `eraseDataSubject(subject, { keys?, copies, shared, 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 (each wrapped by `auditedPersonalDataErasure`, whose entries prove the erasure with or without a key), `shared`, the copies no tenant confines (the outbox, the job store), erased once, 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 |
2185
+ | `eraseDataSubject(subject, { keys?, copies, shared, 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 (each wrapped by `auditedPersonalDataErasure`, whose entries prove the erasure with or without a key), `shared`, the copies no tenant confines (the outbox, the job store), erased once, every projection fed by the store rebuilt. A copy or a rebuild 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 |
2186
2186
  | `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 |
2187
2187
  | `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 |
2188
2188
  | `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 |
@@ -2,12 +2,13 @@ import type { DataSubjectErasure } from './data-subject-erasure.js';
2
2
  import type { DataSubjectErasureReport } from './data-subject-erasure-report.js';
3
3
  /**
4
4
  * The right to erasure of one data subject: destroys the key its personal values were sealed
5
- * with, so the stored events and snapshots read them as erased; erases every copy a context keeps
5
+ * with, so the stored events and what snapshots sealed read them as erased; erases every copy a context keeps
6
6
  * of the person in clear, in every tenant; then rebuilds every projection fed by the store, so no
7
7
  * read model keeps a clear copy. The copies and the rebuilds run even when the subject had no key
8
8
  * left, and even when the erasure of the key failed, since the key may be gone all the same (an
9
- * audit entry that could not be written): the first failure is thrown once they are done, and
10
- * running the erasure again completes it. Only a mistyped id skips the rebuilds. A subject that is
9
+ * audit entry that could not be written). A copy or a rebuild that fails does not stop the next:
10
+ * the first failure is thrown once they are done, and running the erasure again completes it.
11
+ * Only a mistyped id skips the rebuilds. A subject that is
11
12
  * not an opaque identifier is refused before any key is touched: the audited keys write the
12
13
  * subject into the append-only trail, which never holds a name or an email. Give it the keys
13
14
  * wrapped by `auditedSubjectKeys` and the copies wrapped by `auditedPersonalDataErasure` of
@@ -1 +1 @@
1
- {"version":3,"file":"erase-data-subject.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/erase-data-subject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAkB9E;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAiBpH"}
1
+ {"version":3,"file":"erase-data-subject.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/erase-data-subject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAuB9E;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqBpH"}
@@ -3,12 +3,13 @@ import { NotADataSubjectIdError } from './not-a-data-subject-id-error.js';
3
3
  import { UnknownDataSubjectError } from './unknown-data-subject-error.js';
4
4
  /**
5
5
  * The right to erasure of one data subject: destroys the key its personal values were sealed
6
- * with, so the stored events and snapshots read them as erased; erases every copy a context keeps
6
+ * with, so the stored events and what snapshots sealed read them as erased; erases every copy a context keeps
7
7
  * of the person in clear, in every tenant; then rebuilds every projection fed by the store, so no
8
8
  * read model keeps a clear copy. The copies and the rebuilds run even when the subject had no key
9
9
  * left, and even when the erasure of the key failed, since the key may be gone all the same (an
10
- * audit entry that could not be written): the first failure is thrown once they are done, and
11
- * running the erasure again completes it. Only a mistyped id skips the rebuilds. A subject that is
10
+ * audit entry that could not be written). A copy or a rebuild that fails does not stop the next:
11
+ * the first failure is thrown once they are done, and running the erasure again completes it.
12
+ * Only a mistyped id skips the rebuilds. A subject that is
12
13
  * not an opaque identifier is refused before any key is touched: the audited keys write the
13
14
  * subject into the append-only trail, which never holds a name or an email. Give it the keys
14
15
  * wrapped by `auditedSubjectKeys` and the copies wrapped by `auditedPersonalDataErasure` of
@@ -24,9 +25,13 @@ export async function eraseDataSubject(subject, parts) {
24
25
  if (await isMistyped(subject, { erasure, copies }, parts.isKnown)) {
25
26
  throw new UnknownDataSubjectError(subject);
26
27
  }
27
- const rebuilt = await rebuildAll(parts.rebuilds ?? []);
28
- throwFirstFailure({ erasure, copies });
29
- return { erased: erasure.status === 'fulfilled' && erasure.value, copies: copies.reached, rebuilt };
28
+ const rebuilds = await rebuildAll(parts.rebuilds ?? []);
29
+ throwFirstFailure({ erasure, copies }, rebuilds);
30
+ return {
31
+ erased: erasure.status === 'fulfilled' && erasure.value,
32
+ copies: copies.reached,
33
+ rebuilt: rebuilds.replayed,
34
+ };
30
35
  }
31
36
  /** The key of the subject, when there is a store of keys at all: without one, no key was destroyed. */
32
37
  function eraseKeyOf(subject, keys) {
@@ -67,19 +72,27 @@ async function isMistyped(subject, { erasure, copies }, isKnown) {
67
72
  }
68
73
  return !(await isKnown(subject));
69
74
  }
70
- function throwFirstFailure({ erasure, copies }) {
75
+ function throwFirstFailure({ erasure, copies }, rebuilds) {
71
76
  if (erasure.status === 'rejected') {
72
77
  throw erasure.reason;
73
78
  }
74
- if (copies.failures.length > 0) {
75
- throw copies.failures[0];
79
+ const failures = [...copies.failures, ...rebuilds.failures];
80
+ if (failures.length > 0) {
81
+ throw failures[0];
76
82
  }
77
83
  }
84
+ /** Every projection, one after the other: a rebuild that fails does not leave the next with its clear copy. */
78
85
  async function rebuildAll(projections) {
79
- const rebuilt = {};
86
+ const replayed = {};
87
+ const failures = [];
80
88
  for (const projection of projections) {
81
- rebuilt[projection.name] = (await projection.rebuild()).replayed;
89
+ try {
90
+ replayed[projection.name] = (await projection.rebuild()).replayed;
91
+ }
92
+ catch (error) {
93
+ failures.push(error);
94
+ }
82
95
  }
83
- return rebuilt;
96
+ return { replayed, failures };
84
97
  }
85
98
  //# sourceMappingURL=erase-data-subject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"erase-data-subject.js","sourceRoot":"","sources":["../../../src/application/personal-data/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K,UAAU,IAAI,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1G,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,iBAAiB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAW;IACrD,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAClC,MAAM,OAAO,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,WAA2C;IACnE,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC;IACnE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"erase-data-subject.js","sourceRoot":"","sources":["../../../src/application/personal-data/erase-data-subject.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8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: a snapshot of another version is ignored, the stream replayed from its start. */
9
9
  readonly version: number;
10
- /** The state to keep, as plain data. */
10
+ /** The state to keep, as plain data, a personal value sealed with `personalData` as in an event: an erasure reaches nothing else. */
11
11
  encode(aggregate: A): object;
12
12
  decode(data: StoredEventData): S;
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot-policy.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/snapshot-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAE5E,0GAA0G;AAC1G,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8HAA8H;IAC9H,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7B,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,CAAC,CAAC;CAClC"}
1
+ {"version":3,"file":"snapshot-policy.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/event-sourcing/snapshot-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAE5E,0GAA0G;AAC1G,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8HAA8H;IAC9H,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qIAAqI;IACrI,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7B,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,CAAC,CAAC;CAClC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/kernel",
3
- "version": "0.106.0",
3
+ "version": "0.108.0",
4
4
  "description": "Framework-agnostic Domain-Driven Design (DDD) building blocks for TypeScript: aggregates, entities, value objects, domain events, CQRS command and query buses, unit of work and application ports, with an in-memory event bus.",
5
5
  "keywords": [
6
6
  "ddd",