@ddd-ts-kit/kernel 0.97.0 → 0.99.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:298a9aa1069515a0 -->
2
+ <!-- translation-of: README.md sha256:1a8e41caf665b63c -->
3
3
 
4
4
  # @ddd-ts-kit/kernel
5
5
 
@@ -1484,7 +1484,9 @@ d'expiration : celui-ci connaît les *jobs*, les planifications et les instances
1484
1484
  une occurrence et son issue (`succeeded`, `failed` avec le code de l'erreur et jamais son
1485
1485
  message, `skipped-overlap`, `skipped-locked`, `missed`). Un *job* qui échoue n'arrête ni le
1486
1486
  planificateur ni les autres *jobs*, et `runNow` répond `failed` au lieu de rejeter : seul un nom
1487
- inconnu rejette (`UnknownJobError`), et un nom enregistré deux fois lève (`DuplicateJobError`).
1487
+ inconnu rejette (`UnknownJobError`), et un nom enregistré deux fois lève (`DuplicateJobError`). Une exécution réussie d'un *job* par *tenant*
1488
+ porte `tenants`, le nombre de *tenants* pour lesquels il a tourné : `0` veut dire que l'annuaire des
1489
+ *tenants* était vide et que le *job* n'a jamais été appelé.
1488
1490
 
1489
1491
  Une exécution se déroule dans `ExecutionScope`, dans le contexte que construit
1490
1492
  `executionContextOfJob(name, { correlationId, scheduledAt, deadline?, tenantId? })` : origine
package/README.md CHANGED
@@ -1423,7 +1423,8 @@ and instances. A `JobRun` is one occurrence and its outcome (`succeeded`, `faile
1423
1423
  code of the error and never its message, `skipped-overlap`, `skipped-locked`, `missed`). A job
1424
1424
  that fails stops neither the scheduler nor the other jobs, and `runNow` answers `failed`
1425
1425
  instead of rejecting: only an unknown name rejects (`UnknownJobError`), and a name registered
1426
- twice throws (`DuplicateJobError`).
1426
+ twice throws (`DuplicateJobError`). A succeeded run of a per-tenant job carries `tenants`, the
1427
+ number of tenants it ran for: `0` means the tenant directory was empty and the job was never called.
1427
1428
 
1428
1429
  A run happens inside `ExecutionScope`, in the context `executionContextOfJob(name, { correlationId,
1429
1430
  scheduledAt, deadline?, tenantId? })` builds: origin `schedule`, `systemActor(name)`, a correlation of its
@@ -13,6 +13,8 @@ export interface PersonalFields<Row, Table = unknown> {
13
13
  readonly files: readonly (keyof Row & string)[];
14
14
  /** How long the rows keep it, counted from a date column: past that, the purge erases them as `erasure` says. Absent: kept until the person asks. */
15
15
  readonly retention?: Retention<Row>;
16
+ /** The key of the configuration that gives the retention, when the project reads it at run time: the register names it. Never with `retention`. */
17
+ readonly configuredRetention?: string;
16
18
  }
17
19
  export interface PersonalFieldsOptions<Row> {
18
20
  readonly subject: keyof Row & string;
@@ -20,6 +22,12 @@ export interface PersonalFieldsOptions<Row> {
20
22
  readonly erasure: ErasureMode;
21
23
  readonly files?: readonly (keyof Row & string)[];
22
24
  readonly retention?: Retention<Row>;
25
+ /**
26
+ * For a retention the project reads from configuration and purges by itself: the name of the
27
+ * variable or key (`'RETENTION_PERIODS'`). The generated register then says "configured by" it,
28
+ * instead of "until erased". The kit's own purge runs only from a literal `retention`.
29
+ */
30
+ readonly configuredRetention?: string;
23
31
  }
24
32
  /**
25
33
  * Declares, next to the mapper of a table, which of its columns are personal and whose they are:
@@ -30,5 +38,5 @@ export interface PersonalFieldsOptions<Row> {
30
38
  * personal, since an identifier that is personal data (an email) cannot name a data subject, and a
31
39
  * retention that is not one positive unit or that runs from a personal column.
32
40
  */
33
- export declare function personalFields<Row, Table = unknown>(table: Table, { subject, fields, erasure, files, retention }: PersonalFieldsOptions<Row>): PersonalFields<Row, Table>;
41
+ export declare function personalFields<Row, Table = unknown>(table: Table, { subject, fields, erasure, files, retention, configuredRetention }: PersonalFieldsOptions<Row>): PersonalFields<Row, Table>;
34
42
  //# sourceMappingURL=personal-fields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"personal-fields.d.ts","sourceRoot":"","sources":["../../../src/application/personal-data/personal-fields.ts"],"names":[],"mappings":"AA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AAS,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO,EACjD,KAAK,EAAE,KAAK,EACZ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,qBAAqB,CAAC,GAAG,CAAC,GACnG,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,CAgC5B"}
@@ -9,7 +9,7 @@ import { InvalidPersonalFieldsError } from './invalid-personal-fields-error.js';
9
9
  * personal, since an identifier that is personal data (an email) cannot name a data subject, and a
10
10
  * retention that is not one positive unit or that runs from a personal column.
11
11
  */
12
- export function personalFields(table, { subject, fields, erasure, files = [], retention }) {
12
+ export function personalFields(table, { subject, fields, erasure, files = [], retention, configuredRetention }) {
13
13
  const personal = [...fields, ...files];
14
14
  if (fields.length === 0) {
15
15
  throw new InvalidPersonalFieldsError('names no personal field');
@@ -23,6 +23,20 @@ export function personalFields(table, { subject, fields, erasure, files = [], re
23
23
  if (retention !== undefined) {
24
24
  assertRetention(retention, personal);
25
25
  }
26
- return { table, subject, fields, erasure, files, ...(retention === undefined ? {} : { retention }) };
26
+ assertConfiguredRetention(configuredRetention, retention);
27
+ return {
28
+ table,
29
+ subject,
30
+ fields,
31
+ erasure,
32
+ files,
33
+ ...(retention === undefined ? {} : { retention }),
34
+ ...(configuredRetention === undefined ? {} : { configuredRetention }),
35
+ };
36
+ }
37
+ function assertConfiguredRetention(configuredRetention, retention) {
38
+ if (configuredRetention !== undefined && (retention !== undefined || configuredRetention.trim() === '')) {
39
+ throw new InvalidPersonalFieldsError('gives a retention and a configuration key for it: a literal retention, or the key of the configuration, not both and not empty');
40
+ }
27
41
  }
28
42
  //# sourceMappingURL=personal-fields.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"personal-fields.js","sourceRoot":"","sources":["../../../src/application/personal-data/personal-fields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AA0B7E;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAY,EACZ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG,EAAE,EAAE,SAAS,EAA8B;IAE/E,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;IAEvC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,0BAA0B,CAAC,yBAAyB,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,0BAA0B,CAClC,6BAA6B,OAAO,4DAA4D,CACjG,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC/C,MAAM,IAAI,0BAA0B,CAAC,sBAAsB,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;AACvG,CAAC"}
1
+ {"version":3,"file":"personal-fields.js","sourceRoot":"","sources":["../../../src/application/personal-data/personal-fields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,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kB;IAC5F,IAAI,mBAAmB,KAAK,SAAS,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACxG,MAAM,IAAI,0BAA0B,CAClC,gIAAgI,CACjI,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -7,6 +7,11 @@ export interface JobRun {
7
7
  /** Present when the job ran. */
8
8
  readonly startedAt?: Date;
9
9
  readonly durationMs?: number;
10
+ /**
11
+ * How many tenants a succeeded run of a per-tenant job ran for; 0 when the directory had none,
12
+ * and the job was never called. Absent for a global job.
13
+ */
14
+ readonly tenants?: number;
10
15
  /** The `code` of what the job threw, or `UNEXPECTED_ERROR`. */
11
16
  readonly errorCode?: string;
12
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"job-run.d.ts","sourceRoot":"","sources":["../../../src/application/scheduling/job-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,oGAAoG;AACpG,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAC3B,gCAAgC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B"}
1
+ {"version":3,"file":"job-run.d.ts","sourceRoot":"","sources":["../../../src/application/scheduling/job-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,oGAAoG;AACpG,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAC3B,gCAAgC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/kernel",
3
- "version": "0.97.0",
3
+ "version": "0.99.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",