@ddd-ts-kit/knex 0.113.1 → 0.114.1

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.
Files changed (3) hide show
  1. package/README.fr.md +6 -6
  2. package/README.md +5 -5
  3. package/package.json +10 -10
package/README.fr.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [English](README.md) · **Français**
2
- <!-- translation-of: README.md sha256:d723d12bcfe5ca31 -->
2
+ <!-- translation-of: README.md sha256:c6d56ebe67625a45 -->
3
3
 
4
4
  # @ddd-ts-kit/knex
5
5
 
@@ -28,7 +28,7 @@ vivent dans l'`infrastructure/` de chaque contexte, et l'unité de travail est c
28
28
  `UnitOfWork` dans lequel le bus de commandes exécute chaque commande, et au `KnexContext` par
29
29
  lequel chaque adaptateur atteint la base de données.
30
30
 
31
- ![Le bus de commandes appelle run sur le port UnitOfWork ; les repositories, les lecteurs, les stores du package et le journal d'audit appellent executor sur le port KnexContext ; les deux ports sont l'objet unique que renvoie createKnexUnitOfWork, qui garde la transaction ouverte dans un AsyncLocalStorage : chaque instruction d'une commande s'exécute ainsi dans une seule transaction PostgreSQL, avec un schéma par contexte](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/knex-place-in-an-application.fr.svg)
31
+ ![Le bus de commandes appelle run sur le port UnitOfWork ; les repositories, les lecteurs, les stores du package et le journal d'audit appellent executor sur le port KnexContext ; les deux ports sont l'objet unique que renvoie createKnexUnitOfWork, qui garde la transaction ouverte dans un AsyncLocalStorage : chaque instruction d'une commande s'exécute ainsi dans une seule transaction PostgreSQL, avec un schéma par contexte](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/knex-place-in-an-application.fr.svg)
32
32
 
33
33
  Plutôt que de faire descendre une transaction le long des appels, ce qui met un type knex dans
34
34
  chaque signature, du gestionnaire (handler) à l'adaptateur, et fait de son oubli un bogue
@@ -397,7 +397,7 @@ autre ligne détient sous une contrainte d'unicité (un e-mail) est refusée par
397
397
  `optimisticUpdate` lève `UniqueViolationError` (code `CONFLICT`, 409), pas une mise à jour
398
398
  perdue ; sur MySQL, qui n'a pas de cible de conflit et dont `INSERT IGNORE` écarte aussi cette ligne, l'utilitaire demande si une ligne détient la clé quand rien n'a été écrit, et lève `UniqueViolationError` quand aucune ne la détient. Deux premiers enregistrements d'un même agrégat faits en même temps (une requête livrée deux fois) ne sont pas refusés pour la valeur unique qu'ils écrivent tous les deux : sur PostgreSQL, une cible de conflit sur la clé seule les laisse se rencontrer d'abord sur l'autre index unique, si bien que l'utilitaire insère par une instruction qui passe sur toute valeur unique, et seulement quand elle n'a rien écrit par une seconde qui nomme la clé. Celui qui a perdu n'écrit aucune ligne, une `ConcurrencyError`.
399
399
 
400
- ![Deux transactions chargent la facture inv-1 à la version 3 ; la première sauvegarde, sa mise à jour trouve la version 3 et la ligne passe à la version 4 ; la seconde sauvegarde ensuite, sa mise à jour attend toujours la version 3, n'écrit aucune ligne, et optimisticUpdate lève ConcurrencyError, code CONCURRENCY_CONFLICT](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/persistence-optimistic-concurrency.fr.svg)
400
+ ![Deux transactions chargent la facture inv-1 à la version 3 ; la première sauvegarde, sa mise à jour trouve la version 3 et la ligne passe à la version 4 ; la seconde sauvegarde ensuite, sa mise à jour attend toujours la version 3, n'écrit aucune ligne, et optimisticUpdate lève ConcurrencyError, code CONCURRENCY_CONFLICT](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/persistence-optimistic-concurrency.fr.svg)
401
401
 
402
402
  Le second écrivain est refusé au lieu d'écraser le premier en silence. Rien ne le retente pour
403
403
  vous : l'appelant reçoit la `ConcurrencyError` et décide s'il recharge la facture.
@@ -627,7 +627,7 @@ base de données :
627
627
  Ce que le curseur apporte, sur des factures triées par montant, quand une ligne est insérée entre
628
628
  deux pages :
629
629
 
630
- ![Des factures dans un ordre total par montant puis par id ; la page 1 lit quatre lignes pour une limite de 3 et garde comme curseur la position de la dernière, montant 40 et id inv-7 ; après l'insertion d'une facture de 10, la page 2 par offset 3 lit inv-7 une seconde fois, tandis que la page 2 après le curseur compare la position comme un tuple et renvoie inv-9, inv-2 et inv-4 : rien de répété, rien de sauté, aucun comptage](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/knex-cursor-page.fr.svg)
630
+ ![Des factures dans un ordre total par montant puis par id ; la page 1 lit quatre lignes pour une limite de 3 et garde comme curseur la position de la dernière, montant 40 et id inv-7 ; après l'insertion d'une facture de 10, la page 2 par offset 3 lit inv-7 une seconde fois, tandis que la page 2 après le curseur compare la position comme un tuple et renvoie inv-9, inv-2 et inv-4 : rien de répété, rien de sauté, aucun comptage](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/knex-cursor-page.fr.svg)
631
631
 
632
632
  ## Isolation des tenants
633
633
 
@@ -635,7 +635,7 @@ Quatre stratégies, choisies par projet ([Multitenance](../../docs/concepts/mult
635
635
  dit quand chacune convient). Chacune est prouvée ici par `tenantIsolationContract` de
636
636
  `@ddd-ts-kit/testing/contracts`, sur PGlite et sur PostgreSQL.
637
637
 
638
- ![Les quatre stratégies, de la plus partagée à la plus séparée, et les helpers de chacune : tables partagées avec tenantColumn, tenantTable, ownTenantTable, tenantRow et whereTenant ; sécurité au niveau des lignes avec enableTenantIsolation ou tenantIsolationStatements, tenantSession et un rôle sans BYPASSRLS ; schéma par tenant avec tenantSchemaOf, tenantSchemaTable, tenantOfMigration, migrateTenantSchema et tenantSearchPath ; base par tenant avec TenantDatabases, createTenantRoutedUnitOfWork et migrateEveryTenant](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/knex-tenant-isolation-helpers.fr.svg)
638
+ ![Les quatre stratégies, de la plus partagée à la plus séparée, et les helpers de chacune : tables partagées avec tenantColumn, tenantTable, ownTenantTable, tenantRow et whereTenant ; sécurité au niveau des lignes avec enableTenantIsolation ou tenantIsolationStatements, tenantSession et un rôle sans BYPASSRLS ; schéma par tenant avec tenantSchemaOf, tenantSchemaTable, tenantOfMigration, migrateTenantSchema et tenantSearchPath ; base par tenant avec TenantDatabases, createTenantRoutedUnitOfWork et migrateEveryTenant](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/knex-tenant-isolation-helpers.fr.svg)
639
639
 
640
640
  **Tables partagées.** Une table par agrégat, une colonne `tenant_id`, et chaque instruction
641
641
  restreinte par le kit plutôt que par une condition écrite à la main :
@@ -903,7 +903,7 @@ La vie d'un enregistrement dans la table `outbox`. Le relais de `@ddd-ts-kit/eve
903
903
  par `claimBatch`, `markPublished` et `markFailed` ; `retryDead`, `purgePublished` et `stats` sont
904
904
  appelés par un opérateur ou par un job planifié, jamais par le relais :
905
905
 
906
- ![Un enregistrement est ajouté en attente par la validation de la commande ; le relais le réclame quand il est dû et le publie, puis le marque publié, et purgePublished le supprime plus tard ; une publication en échec le laisse en attente, retenté après un délai exponentiel ; après la dernière tentative il est mort, jusqu'à ce que retryDead le remette en attente ; stats compte les enregistrements en attente, en échec et morts](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/transactional-outbox-record-lifecycle.fr.svg)
906
+ ![Un enregistrement est ajouté en attente par la validation de la commande ; le relais le réclame quand il est dû et le publie, puis le marque publié, et purgePublished le supprime plus tard ; une publication en échec le laisse en attente, retenté après un délai exponentiel ; après la dernière tentative il est mort, jusqu'à ce que retryDead le remette en attente ; stats compte les enregistrements en attente, en échec et morts](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/transactional-outbox-record-lifecycle.fr.svg)
907
907
 
908
908
  ## Event store
909
909
 
package/README.md CHANGED
@@ -25,7 +25,7 @@ ports and the application its query ports; the adapters written with this packag
25
25
  the hinge: `createKnexUnitOfWork(db)` answers the `UnitOfWork` the command bus runs every
26
26
  command in, and the `KnexContext` every adapter reaches the database through.
27
27
 
28
- ![The command bus calls run on the UnitOfWork port; repositories, readers, the stores of the package and the audit trail call executor on the KnexContext port; both ports are the one object createKnexUnitOfWork answers, which keeps the open transaction in an AsyncLocalStorage, so every statement of a command runs in one PostgreSQL transaction, one schema per context](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/knex-place-in-an-application.svg)
28
+ ![The command bus calls run on the UnitOfWork port; repositories, readers, the stores of the package and the audit trail call executor on the KnexContext port; both ports are the one object createKnexUnitOfWork answers, which keeps the open transaction in an AsyncLocalStorage, so every statement of a command runs in one PostgreSQL transaction, one schema per context](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/knex-place-in-an-application.svg)
29
29
 
30
30
  Instead of handing a transaction down the calls, which puts a knex type in every signature from
31
31
  the handler to the adapter and makes forgetting it a silent bug, the adapter asks the context
@@ -381,7 +381,7 @@ ignores a conflict on `conflict` alone (the id): a row that takes a value anothe
381
381
  under a unique constraint (an email) is refused by the database, and `optimisticUpdate` raises
382
382
  `UniqueViolationError` (code `CONFLICT`, 409), not a lost update; on MySQL, which has no conflict target and whose `INSERT IGNORE` skips that row too, the helper asks whether a row holds the key when nothing was written, and raises `UniqueViolationError` when none does. Two first saves of one aggregate made at once (a request delivered twice) are not refused for the unique value they both write: on PostgreSQL a conflict target on the key alone lets them meet on the other unique index first, so the helper inserts with a statement that skips on any unique value, and only when it wrote nothing with a second one that names the key. The one that lost writes no row, a `ConcurrencyError`.
383
383
 
384
- ![Two transactions load invoice inv-1 at version 3; the first saves, its update matches version 3 and the row moves to version 4; the second saves afterwards, its update still expects version 3, writes no row, and optimisticUpdate throws ConcurrencyError, code CONCURRENCY_CONFLICT](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/persistence-optimistic-concurrency.svg)
384
+ ![Two transactions load invoice inv-1 at version 3; the first saves, its update matches version 3 and the row moves to version 4; the second saves afterwards, its update still expects version 3, writes no row, and optimisticUpdate throws ConcurrencyError, code CONCURRENCY_CONFLICT](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/persistence-optimistic-concurrency.svg)
385
385
 
386
386
  The second writer is refused instead of silently overwriting the first. Nothing retries it for
387
387
  you: the caller receives the `ConcurrencyError` and decides whether to load the invoice again.
@@ -602,7 +602,7 @@ The rules these examples hold, and that the tests of this package check on a rea
602
602
 
603
603
  What the cursor buys, on invoices sorted by amount, when a row is inserted between two pages:
604
604
 
605
- ![Invoices in total order by amount then id; page 1 reads four rows for a limit of 3 and keeps the position of the last, amount 40 and id inv-7, as its cursor; after an invoice of 10 is inserted, page 2 by offset 3 reads inv-7 a second time, while page 2 after the cursor compares the position as a tuple and answers inv-9, inv-2 and inv-4, nothing repeated, nothing skipped, no count](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/knex-cursor-page.svg)
605
+ ![Invoices in total order by amount then id; page 1 reads four rows for a limit of 3 and keeps the position of the last, amount 40 and id inv-7, as its cursor; after an invoice of 10 is inserted, page 2 by offset 3 reads inv-7 a second time, while page 2 after the cursor compares the position as a tuple and answers inv-9, inv-2 and inv-4, nothing repeated, nothing skipped, no count](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/knex-cursor-page.svg)
606
606
 
607
607
  ## Tenant isolation
608
608
 
@@ -610,7 +610,7 @@ Four strategies, chosen per project ([Multitenancy](../../docs/concepts/multiten
610
610
  when each fits). Every one of them is proven here by `tenantIsolationContract` of
611
611
  `@ddd-ts-kit/testing/contracts`, on PGlite and on PostgreSQL.
612
612
 
613
- ![The four strategies from the most shared to the most separated, and the helpers of each: shared tables with tenantColumn, tenantTable, ownTenantTable, tenantRow and whereTenant; row-level security with enableTenantIsolation or tenantIsolationStatements, tenantSession and a role without BYPASSRLS; schema per tenant with tenantSchemaOf, tenantSchemaTable, tenantOfMigration, migrateTenantSchema and tenantSearchPath; database per tenant with TenantDatabases, createTenantRoutedUnitOfWork and migrateEveryTenant](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/knex-tenant-isolation-helpers.svg)
613
+ ![The four strategies from the most shared to the most separated, and the helpers of each: shared tables with tenantColumn, tenantTable, ownTenantTable, tenantRow and whereTenant; row-level security with enableTenantIsolation or tenantIsolationStatements, tenantSession and a role without BYPASSRLS; schema per tenant with tenantSchemaOf, tenantSchemaTable, tenantOfMigration, migrateTenantSchema and tenantSearchPath; database per tenant with TenantDatabases, createTenantRoutedUnitOfWork and migrateEveryTenant](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/knex-tenant-isolation-helpers.svg)
614
614
 
615
615
  **Shared tables.** One table per aggregate, a `tenant_id` column, and every statement confined
616
616
  by the kit instead of by a condition written by hand:
@@ -864,7 +864,7 @@ The life of one record in the `outbox` table. The relay of `@ddd-ts-kit/events`
864
864
  `claimBatch`, `markPublished` and `markFailed`; `retryDead`, `purgePublished` and `stats` are
865
865
  called by an operator or a scheduled job, never by the relay:
866
866
 
867
- ![A record is appended pending by the commit of the command; the relay claims it when due and publishes it, then marks it published, and purgePublished removes it later; a failed publication leaves it pending, retried after an exponential backoff; after the last attempt it is dead until retryDead puts it back pending; stats counts pending, failed and dead records](https://raw.githubusercontent.com/gbourgeat/ddd-ts-kit/main/docs/assets/diagrams/transactional-outbox-record-lifecycle.svg)
867
+ ![A record is appended pending by the commit of the command; the relay claims it when due and publishes it, then marks it published, and purgePublished removes it later; a failed publication leaves it pending, retried after an exponential backoff; after the last attempt it is dead until retryDead puts it back pending; stats counts pending, failed and dead records](https://raw.githubusercontent.com/ddd-ts-kit/ddd-ts-kit/main/docs/assets/diagrams/transactional-outbox-record-lifecycle.svg)
868
868
 
869
869
  ## Event store
870
870
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/knex",
3
- "version": "0.113.1",
3
+ "version": "0.114.1",
4
4
  "description": "Knex adapters for the kernel ports: unit of work, transactional outbox store, processed-event store, PostgreSQL event store, background job store, process store.",
5
5
  "keywords": [
6
6
  "ddd",
@@ -17,11 +17,11 @@
17
17
  "license": "MIT",
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "git+https://github.com/gbourgeat/ddd-ts-kit.git",
20
+ "url": "git+https://github.com/ddd-ts-kit/ddd-ts-kit.git",
21
21
  "directory": "packages/knex"
22
22
  },
23
- "homepage": "https://gbourgeat.github.io/ddd-ts-kit/packages/knex/",
24
- "bugs": "https://github.com/gbourgeat/ddd-ts-kit/issues",
23
+ "homepage": "https://ddd-ts-kit.github.io/ddd-ts-kit/packages/knex/",
24
+ "bugs": "https://github.com/ddd-ts-kit/ddd-ts-kit/issues",
25
25
  "publishConfig": {
26
26
  "access": "public",
27
27
  "provenance": true
@@ -41,20 +41,20 @@
41
41
  "dist"
42
42
  ],
43
43
  "dependencies": {
44
- "@ddd-ts-kit/kernel": "0.113.1",
45
- "@ddd-ts-kit/events": "0.113.1",
46
- "@ddd-ts-kit/scheduling": "0.113.1"
44
+ "@ddd-ts-kit/kernel": "0.114.1",
45
+ "@ddd-ts-kit/events": "0.114.1",
46
+ "@ddd-ts-kit/scheduling": "0.114.1"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "knex": "^3.0.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "knex": "^3.3.0",
53
- "@ddd-ts-kit/testing": "0.113.1",
53
+ "@ddd-ts-kit/testing": "0.114.1",
54
54
  "pg": "^8.23.1",
55
55
  "@types/pg": "^8.23.1",
56
- "@electric-sql/pglite": "0.5.15",
57
- "@electric-sql/pglite-socket": "0.2.18",
56
+ "@electric-sql/pglite": "0.5.16",
57
+ "@electric-sql/pglite-socket": "0.2.19",
58
58
  "better-sqlite3": "^12.11.1"
59
59
  }
60
60
  }