@ddd-ts-kit/opensearch 0.0.0 → 0.108.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 (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.fr.md +222 -0
  3. package/README.md +208 -0
  4. package/dist/errors/invalid-index-name-error.d.ts +12 -0
  5. package/dist/errors/invalid-index-name-error.d.ts.map +1 -0
  6. package/dist/errors/invalid-index-name-error.js +17 -0
  7. package/dist/errors/invalid-index-name-error.js.map +1 -0
  8. package/dist/errors/open-search-request-error.d.ts +14 -0
  9. package/dist/errors/open-search-request-error.d.ts.map +1 -0
  10. package/dist/errors/open-search-request-error.js +21 -0
  11. package/dist/errors/open-search-request-error.js.map +1 -0
  12. package/dist/errors/open-search-unavailable-error.d.ts +10 -0
  13. package/dist/errors/open-search-unavailable-error.d.ts.map +1 -0
  14. package/dist/errors/open-search-unavailable-error.js +13 -0
  15. package/dist/errors/open-search-unavailable-error.js.map +1 -0
  16. package/dist/errors/unprovisioned-index-error.d.ts +11 -0
  17. package/dist/errors/unprovisioned-index-error.d.ts.map +1 -0
  18. package/dist/errors/unprovisioned-index-error.js +15 -0
  19. package/dist/errors/unprovisioned-index-error.js.map +1 -0
  20. package/dist/errors/unsupported-rebuild-error.d.ts +11 -0
  21. package/dist/errors/unsupported-rebuild-error.d.ts.map +1 -0
  22. package/dist/errors/unsupported-rebuild-error.js +15 -0
  23. package/dist/errors/unsupported-rebuild-error.js.map +1 -0
  24. package/dist/index.d.ts +12 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +8 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/mapping/decimal-key.d.ts +9 -0
  29. package/dist/mapping/decimal-key.d.ts.map +1 -0
  30. package/dist/mapping/decimal-key.js +35 -0
  31. package/dist/mapping/decimal-key.js.map +1 -0
  32. package/dist/mapping/document.mapper.d.ts +25 -0
  33. package/dist/mapping/document.mapper.d.ts.map +1 -0
  34. package/dist/mapping/document.mapper.js +94 -0
  35. package/dist/mapping/document.mapper.js.map +1 -0
  36. package/dist/mapping/mapping-of.d.ts +9 -0
  37. package/dist/mapping/mapping-of.d.ts.map +1 -0
  38. package/dist/mapping/mapping-of.js +38 -0
  39. package/dist/mapping/mapping-of.js.map +1 -0
  40. package/dist/mapping/reserved-fields.d.ts +12 -0
  41. package/dist/mapping/reserved-fields.d.ts.map +1 -0
  42. package/dist/mapping/reserved-fields.js +12 -0
  43. package/dist/mapping/reserved-fields.js.map +1 -0
  44. package/dist/mapping/stored-field.d.ts +7 -0
  45. package/dist/mapping/stored-field.d.ts.map +1 -0
  46. package/dist/mapping/stored-field.js +2 -0
  47. package/dist/mapping/stored-field.js.map +1 -0
  48. package/dist/naming/index-names.d.ts +20 -0
  49. package/dist/naming/index-names.d.ts.map +1 -0
  50. package/dist/naming/index-names.js +46 -0
  51. package/dist/naming/index-names.js.map +1 -0
  52. package/dist/query/plan-to-search.d.ts +13 -0
  53. package/dist/query/plan-to-search.d.ts.map +1 -0
  54. package/dist/query/plan-to-search.js +24 -0
  55. package/dist/query/plan-to-search.js.map +1 -0
  56. package/dist/query/predicate-to-query.d.ts +11 -0
  57. package/dist/query/predicate-to-query.d.ts.map +1 -0
  58. package/dist/query/predicate-to-query.js +48 -0
  59. package/dist/query/predicate-to-query.js.map +1 -0
  60. package/dist/store/error-type-of.d.ts +4 -0
  61. package/dist/store/error-type-of.d.ts.map +1 -0
  62. package/dist/store/error-type-of.js +7 -0
  63. package/dist/store/error-type-of.js.map +1 -0
  64. package/dist/store/field-of.d.ts +3 -0
  65. package/dist/store/field-of.d.ts.map +1 -0
  66. package/dist/store/field-of.js +6 -0
  67. package/dist/store/field-of.js.map +1 -0
  68. package/dist/store/index-provisioning.d.ts +24 -0
  69. package/dist/store/index-provisioning.d.ts.map +1 -0
  70. package/dist/store/index-provisioning.js +53 -0
  71. package/dist/store/index-provisioning.js.map +1 -0
  72. package/dist/store/is-json-object.d.ts +3 -0
  73. package/dist/store/is-json-object.d.ts.map +1 -0
  74. package/dist/store/is-json-object.js +5 -0
  75. package/dist/store/is-json-object.js.map +1 -0
  76. package/dist/store/open-search-documents.d.ts +44 -0
  77. package/dist/store/open-search-documents.d.ts.map +1 -0
  78. package/dist/store/open-search-documents.js +82 -0
  79. package/dist/store/open-search-documents.js.map +1 -0
  80. package/dist/store/open-search-read-model-options.d.ts +24 -0
  81. package/dist/store/open-search-read-model-options.d.ts.map +1 -0
  82. package/dist/store/open-search-read-model-options.js +2 -0
  83. package/dist/store/open-search-read-model-options.js.map +1 -0
  84. package/dist/store/open-search-read-model-store.d.ts +17 -0
  85. package/dist/store/open-search-read-model-store.d.ts.map +1 -0
  86. package/dist/store/open-search-read-model-store.js +25 -0
  87. package/dist/store/open-search-read-model-store.js.map +1 -0
  88. package/dist/store/open-search-read-model-table.d.ts +40 -0
  89. package/dist/store/open-search-read-model-table.d.ts.map +1 -0
  90. package/dist/store/open-search-read-model-table.js +139 -0
  91. package/dist/store/open-search-read-model-table.js.map +1 -0
  92. package/dist/store/open-search-tenancy.d.ts +15 -0
  93. package/dist/store/open-search-tenancy.d.ts.map +1 -0
  94. package/dist/store/open-search-tenancy.js +2 -0
  95. package/dist/store/open-search-tenancy.js.map +1 -0
  96. package/dist/store/refusal-of.d.ts +5 -0
  97. package/dist/store/refusal-of.d.ts.map +1 -0
  98. package/dist/store/refusal-of.js +9 -0
  99. package/dist/store/refusal-of.js.map +1 -0
  100. package/dist/store/tenant-targets.d.ts +41 -0
  101. package/dist/store/tenant-targets.d.ts.map +1 -0
  102. package/dist/store/tenant-targets.js +67 -0
  103. package/dist/store/tenant-targets.js.map +1 -0
  104. package/dist/testing.d.ts +2 -0
  105. package/dist/testing.d.ts.map +1 -0
  106. package/dist/testing.js +2 -0
  107. package/dist/testing.js.map +1 -0
  108. package/dist/transport/fetch-transport-options.d.ts +17 -0
  109. package/dist/transport/fetch-transport-options.d.ts.map +1 -0
  110. package/dist/transport/fetch-transport-options.js +2 -0
  111. package/dist/transport/fetch-transport-options.js.map +1 -0
  112. package/dist/transport/fetch-transport.d.ts +8 -0
  113. package/dist/transport/fetch-transport.d.ts.map +1 -0
  114. package/dist/transport/fetch-transport.js +56 -0
  115. package/dist/transport/fetch-transport.js.map +1 -0
  116. package/dist/transport/open-search-transport.d.ts +24 -0
  117. package/dist/transport/open-search-transport.d.ts.map +1 -0
  118. package/dist/transport/open-search-transport.js +2 -0
  119. package/dist/transport/open-search-transport.js.map +1 -0
  120. package/package.json +58 -9
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gary Bourgeat
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.fr.md ADDED
@@ -0,0 +1,222 @@
1
+ [English](README.md) · **Français**
2
+ <!-- translation-of: README.md sha256:57523eb375c8c2ae -->
3
+
4
+ # @ddd-ts-kit/opensearch
5
+
6
+ Le `ReadModelStore` du noyau sur OpenSearch : le modèle de lecture d'une projection tenu dans un
7
+ index, interrogé avec les critères du noyau traduits dans le DSL de requête, ses écritures
8
+ ordonnées par l'estampille de l'événement qui les a faites, et les documents des locataires tenus
9
+ à part par un index par locataire, ou par un champ de locataire et un alias filtré par locataire.
10
+ Il ne dépend d'aucune bibliothèque cliente : il parle l'API REST par un transport de quelques
11
+ lignes. Rien dans `domain/` ni `application/` n'importe ce paquet : un projecteur écrit sur le port
12
+ de son modèle de lecture, et la plateforme lie cet adaptateur.
13
+
14
+ ```
15
+ npm i @ddd-ts-kit/opensearch
16
+ ```
17
+
18
+ `init` ne le câble pas : la composition ci-dessous s'écrit à la main, et
19
+ [la décision](../../docs/adr/0008-a-read-model-store-on-opensearch.fr.md) consigne chaque choix.
20
+
21
+ ## Racine de composition
22
+
23
+ <!-- checked sample -->
24
+ ```ts
25
+ import { AsyncLocalStorageExecutionScope, ReadModelStore, defineCriteria } from '@ddd-ts-kit/kernel';
26
+ import { OpenSearchReadModelStore, fetchTransport } from '@ddd-ts-kit/opensearch';
27
+
28
+ interface AppointmentRow {
29
+ readonly id: string;
30
+ readonly status: 'booked' | 'cancelled';
31
+ readonly startsAt: Date;
32
+ readonly fee: string;
33
+ readonly notes: string | null;
34
+ }
35
+
36
+ // application/ports : le port du modèle de lecture, comme pour tout store
37
+ export abstract class AppointmentList extends ReadModelStore<AppointmentRow> {}
38
+
39
+ const appointmentCriteria = defineCriteria<AppointmentRow>({
40
+ fields: {
41
+ id: { type: 'string', filter: ['eq', 'in'] },
42
+ status: { type: 'string', filter: ['eq', 'in'], sortable: true },
43
+ startsAt: { type: 'instant', filter: ['gte', 'lt', 'between'], sortable: true },
44
+ fee: { type: 'decimal', filter: ['gte', 'lte'], sortable: true },
45
+ },
46
+ defaultSort: [{ field: 'startsAt', direction: 'asc' }],
47
+ tieBreaker: 'id',
48
+ });
49
+
50
+ declare const config: { readonly search: { readonly node: string; readonly username: string; readonly password: string } };
51
+
52
+ export const scope = new AsyncLocalStorageExecutionScope();
53
+
54
+ // infrastructure : l'adaptateur étend le store et n'ajoute rien
55
+ export class SearchAppointmentList extends OpenSearchReadModelStore<AppointmentRow> implements AppointmentList {
56
+ constructor() {
57
+ super({
58
+ transport: fetchTransport({ node: config.search.node, auth: config.search }),
59
+ name: 'scheduling_appointments',
60
+ definition: appointmentCriteria,
61
+ fields: { notes: 'string' }, // gardé avec la ligne, ni filtré ni trié
62
+ tenancy: { strategy: 'attribute', scope }, // ou 'index', ou { strategy: 'none' }
63
+ });
64
+ }
65
+ }
66
+
67
+ // la plateforme, une fois par locataire à sa création (et à chaque démarrage : c'est idempotent)
68
+ export async function provisionTenant(list: SearchAppointmentList, tenantId: string): Promise<void> {
69
+ await list.provision(tenantId);
70
+ }
71
+ ```
72
+
73
+ Un projecteur écrit par le port, comme sur tout store (`@ddd-ts-kit/kernel`, « Projections ») :
74
+
75
+ ```ts
76
+ @Projection('scheduling.appointment-list')
77
+ export class AppointmentListProjection {
78
+ constructor(private readonly appointments: AppointmentList) {}
79
+
80
+ @On(AppointmentBooked)
81
+ booked(event: AppointmentBooked) {
82
+ return this.appointments.upsertIfNewer(event.aggregateId, stampOf(event), () => rowOf(event));
83
+ }
84
+
85
+ @On(AppointmentCancelled)
86
+ cancelled(event: AppointmentCancelled) {
87
+ return this.appointments.delete(event.aggregateId, stampOf(event));
88
+ }
89
+ }
90
+ ```
91
+
92
+ Les options de `OpenSearchReadModelStore` :
93
+
94
+ | Option | Par défaut | |
95
+ |---|---|---|
96
+ | `transport` | requis | `fetchTransport(...)`, ou le client officiel du projet enveloppé dans un `OpenSearchTransport` |
97
+ | `name` | requis | lettres minuscules, chiffres et `_`, au plus 100 : les index et les alias en sont tirés |
98
+ | `definition` | requis | la `CriteriaDefinition` du port de lecture ; ses champs sont mappés et indexés |
99
+ | `fields` | aucun | les autres champs de la ligne avec leur type (`string`, `number`, `boolean`, `instant`, `decimal`), gardés et non indexés |
100
+ | `tenancy` | `{ strategy: 'none' }` | `none`, `index` ou `attribute`, avec le `scope` d'où le locataire est lu et le `field` du locataire (`tenantId`) |
101
+ | `refresh` | aucun | `'wait_for'` : une écriture répond une fois qu'une recherche la voit |
102
+ | `settings` | aucun | les réglages d'un index que le store crée : *shards*, réplicas, intervalle de rafraîchissement |
103
+
104
+ `fetchTransport` prend `node` (`https://search.internal:9200`), `auth` (`{ username, password }`
105
+ pour l'authentification basique, ou `{ authorization }` pour l'en-tête entier, une `ApiKey` ou un
106
+ jeton porteur) et `timeoutMs` (10 000 par défaut). Il répond à tout statut ; il rejette avec
107
+ `OpenSearchUnavailableError` seulement quand aucune réponse n'est venue. Pour utiliser le client
108
+ officiel :
109
+
110
+ ```ts
111
+ const transport: OpenSearchTransport = {
112
+ async request({ method, path, query, body }) {
113
+ const response = await client.transport.request({ method, path, querystring: query, body }, { ignore: [404, 409] });
114
+
115
+ return { status: response.statusCode ?? 200, body: response.body };
116
+ },
117
+ };
118
+ ```
119
+
120
+ ## Locataires
121
+
122
+ | Stratégie | Index | Un locataire est lu et écrit par | Une élévation lit par |
123
+ |---|---|---|---|
124
+ | `none` | `<name>.v1` | l'alias `<name>` | |
125
+ | `index` | `<name>-<tenant>.v1`, un par locataire | l'alias `<name>-<tenant>`, sur l'index de ce locataire | l'alias `<name>`, sur l'index de chaque locataire |
126
+ | `attribute` | `<name>.v1`, partagé | l'alias `<name>-<tenant>`, filtré sur le champ du locataire et routé par le locataire | l'alias `<name>`, sur l'index partagé |
127
+
128
+ Toute lecture et toute écriture passent par un alias, jamais par un index : le store lit de la
129
+ même façon sous les deux stratégies de locataire, et le filtre de l'alias d'un locataire est
130
+ appliqué par OpenSearch lui-même : une requête envoyée par cet alias par un autre programme ne
131
+ voit que les documents de ce locataire. Le store ajoute la même condition à chacune de ses
132
+ recherches. Sous les deux stratégies de locataire :
133
+
134
+ - chaque document porte le locataire du travail dans le champ du locataire (`tenantId` par
135
+ défaut), que le store écrit lui-même, puisqu'une écriture par un alias filtré ne l'écrit pas ;
136
+ quand la ligne a un champ de ce nom, il porte le locataire du travail, quoi que la ligne ait dit ;
137
+ - un `get` et toute écriture atteignent le locataire du travail (`tenantScopeOf`) : un document
138
+ d'un autre locataire est répondu absent, même sous une élévation ;
139
+ - une `search` atteint ce que `tenantReachOf` permet : le locataire du travail ou, sous
140
+ `acrossTenants`, tous les locataires ou ceux qu'elle nomme ;
141
+ - un travail qui ne nomme aucun locataire est refusé avec `NoCurrentTenantError` ;
142
+ - sous `attribute`, l'id d'un document est `<tenant>:<key>`, si bien que deux locataires peuvent
143
+ tenir la même clé.
144
+
145
+ Un locataire devient une partie d'un nom : il est refusé avec `InvalidIndexNameError` s'il n'est
146
+ pas fait de lettres minuscules, de chiffres, de `_` et de `-` (un id de locataire du noyau peut
147
+ tenir des majuscules : `Acme` est refusé plutôt que lu comme `acme`). Un nom de modèle de lecture
148
+ ne tient pas de `-` et un locataire pas de `.`, si bien qu'aucun alias de locataire n'est jamais le
149
+ nom d'un index ni l'alias d'un autre modèle de lecture.
150
+
151
+ **Provisionnement.** Le store ne crée jamais d'index à une écriture, où une faute de frappe dans
152
+ un nom en créerait un : une écriture et une lecture par un alias qui n'existe pas sont refusées
153
+ avec `UnprovisionedIndexError`. La plateforme appelle `ensureMapping()` pour un modèle de lecture
154
+ sans locataires et `provision(tenant)` pour chaque locataire ; les deux sont idempotents, et
155
+ ajoutent à un index existant les champs qui manquent à son *mapping* (un champ mappé avec un autre
156
+ type est refusé par OpenSearch).
157
+
158
+ ## Ce qu'il fait
159
+
160
+ | Méthode du port | Sur OpenSearch |
161
+ |---|---|
162
+ | `get(key)` | `GET /<alias>/_doc/<id>` ; le locataire du document est vérifié, puisqu'un alias filtré ne filtre pas un *get* |
163
+ | `upsertIfNewer`, `delete` | le *get* ci-dessus, puis `PUT /<alias>/_doc/<id>?require_alias=true` avec `op_type=create` pour une clé nouvelle, ou `if_seq_no` et `if_primary_term` du document lu ; sur un conflit il relit, cinq tentatives, puis `ConcurrencyError` |
164
+ | `search(scopedCriteria)` | `POST /<alias>/_search` : chaque opérateur, groupe, tri et page des critères en filtres du DSL de requête ; les lignes supprimées laissées de côté ; une page par décalage comptée exactement (`track_total_hits`) |
165
+ | `ensureMapping()`, `provision(tenant)` | `PUT /<index>`, `PUT /<index>/_mapping`, `POST /_aliases` |
166
+
167
+ Ces *endpoints* sont ceux qu'Elasticsearch partage, mais le store n'a tourné que sur OpenSearch.
168
+
169
+ **Mapping.** Il est `dynamic: 'strict'` : un champ d'une ligne que le modèle de lecture ne déclare
170
+ pas est refusé à l'écriture (`OpenSearchRequestError`, `strict_dynamic_mapping_exception`). Les
171
+ champs de la définition sont indexés : `string` en `keyword` (comparé par point de code, comme les
172
+ critères), `number` en `double`, `boolean`, `instant` en `date` à la milliseconde. Un `decimal` est
173
+ gardé tel qu'il a été écrit et comparé par une clé d'ordre (`_ddd_order.<field>`), un *keyword*
174
+ dont l'ordre des octets est l'ordre des nombres : pas de flottant, pas d'arrondi. L'estampille et
175
+ la suppression vivent dans `_ddd_stamp` et `_ddd_deleted` ; `get` et `search` ne rendent que les
176
+ champs déclarés.
177
+
178
+ **Ordre.** Un remplacement est conditionné au numéro de séquence du document lu : deux événements
179
+ d'une même clé ne s'écrasent jamais à l'aveugle, et la règle de l'estampille est celle du noyau
180
+ (`isNewer`). Une ligne supprimée reste comme une trace avec son estampille : un événement plus
181
+ ancien livré en retard ne la fait pas revenir.
182
+
183
+ **Les pages par curseur** sont des pages par jeu de clés (*keyset*), comme sur les stores SQL : la
184
+ position que tient le curseur devient un filtre (`plan.seek`), pas `search_after`, dont les valeurs
185
+ sont celles du moteur (millisecondes depuis l'époque, clés d'ordre) plutôt que celles de la ligne.
186
+ **Les pages par décalage** utilisent `from` et `size`, bornés par `index.max_result_window`
187
+ (10 000 par défaut).
188
+
189
+ **Rafraîchissement.** Une écriture répond tout de suite, et une recherche la voit après le
190
+ rafraîchissement suivant de l'index (une seconde par défaut) : le côté lecture est cohérent à
191
+ terme, et `get` lit le document tout de suite. `refresh: 'wait_for'` fait attendre chaque écriture
192
+ jusqu'à ce qu'une recherche la voie, au prix de cette attente à chaque écriture ; c'est ce que
193
+ les specs utilisent.
194
+
195
+ ## Limites
196
+
197
+ - **Pas de transaction avec la base.** Une écriture dans OpenSearch ne se valide pas avec la
198
+ marque d'événement traité de l'unité de travail, comme le fait l'écriture d'un store SQL. Une
199
+ panne entre les deux livre l'événement à nouveau, et l'estampille rend cette livraison `stale` :
200
+ rien n'est appliqué deux fois. Une écriture réussie dans une unité de travail qui s'annule n'est
201
+ pas défaite.
202
+ - **Pas encore de reconstruction.** `ProjectionRebuild` refuse ce store avec
203
+ `UnsupportedRebuildError`. Les noms la gardent ouverte : chaque index porte sa génération (`v1`),
204
+ toute lecture et toute écriture passent par un alias, si bien qu'une reconstruction remplit `v2`
205
+ et déplace l'alias en un appel `_aliases`.
206
+ - **Pas de recherche plein texte.** Une `string` est un `keyword` : `contains` est une requête
207
+ *wildcard*, sensible à la casse, et lente sur un gros index. L'analyse de texte, la pertinence et
208
+ les facettes ne sont pas construites.
209
+ - **Une chaîne jusqu'à 32 766 octets** dans un champ filtré : Lucene refuse un terme plus long.
210
+ - Les pages par décalage s'arrêtent à `index.max_result_window` ; au-delà, paginer par curseur.
211
+
212
+ ## Tests
213
+
214
+ `readModelRowsContract` et `criteriaContract` de `@ddd-ts-kit/testing/contracts` (réexportés par
215
+ `@ddd-ts-kit/opensearch/testing`) sous chaque stratégie, et les specs des locataires : deux
216
+ locataires, chacun ne voit et ne change que ses documents, une recherche ne rend jamais ceux d'un
217
+ autre, une élévation lit à travers, un travail sans locataire et un locataire non provisionné sont
218
+ refusés, et aucune écriture ne crée d'index. Elles tournent sur un OpenSearch en mémoire, dans le
219
+ processus, qui sert en HTTP le sous-ensemble de l'API REST que le store appelle, et sur le serveur
220
+ que nomme `DDD_TS_KIT_TEST_OPENSEARCH_URL` : OpenSearch 3 dans le pipeline, avec le plugin de
221
+ sécurité désactivé. `readModelStoreContract`, qui ajoute la reconstruction, ne tourne pas : il n'y
222
+ a pas de reconstruction.
package/README.md ADDED
@@ -0,0 +1,208 @@
1
+ **English** · [Français](README.fr.md)
2
+
3
+ # @ddd-ts-kit/opensearch
4
+
5
+ The kernel `ReadModelStore` on OpenSearch: the read model of a projection kept in an index,
6
+ searched with the criteria of the kernel translated to the query DSL, its writes ordered by the
7
+ stamp of the event that made them, and the documents of tenants kept apart by an index per tenant
8
+ or by a tenant field and a filtered alias per tenant. It depends on no client library: it speaks
9
+ the REST API through a transport of a few lines. Nothing in `domain/` or `application/` imports
10
+ this package: a projector writes to its read model port, and the platform binds this adapter.
11
+
12
+ ```
13
+ npm i @ddd-ts-kit/opensearch
14
+ ```
15
+
16
+ `init` does not wire it: the composition below is written by hand, and
17
+ [the decision record](../../docs/adr/0008-a-read-model-store-on-opensearch.md) states each choice.
18
+
19
+ ## Composition root
20
+
21
+ <!-- checked sample -->
22
+ ```ts
23
+ import { AsyncLocalStorageExecutionScope, ReadModelStore, defineCriteria } from '@ddd-ts-kit/kernel';
24
+ import { OpenSearchReadModelStore, fetchTransport } from '@ddd-ts-kit/opensearch';
25
+
26
+ interface AppointmentRow {
27
+ readonly id: string;
28
+ readonly status: 'booked' | 'cancelled';
29
+ readonly startsAt: Date;
30
+ readonly fee: string;
31
+ readonly notes: string | null;
32
+ }
33
+
34
+ // application/ports: the port of the read model, as for any store
35
+ export abstract class AppointmentList extends ReadModelStore<AppointmentRow> {}
36
+
37
+ const appointmentCriteria = defineCriteria<AppointmentRow>({
38
+ fields: {
39
+ id: { type: 'string', filter: ['eq', 'in'] },
40
+ status: { type: 'string', filter: ['eq', 'in'], sortable: true },
41
+ startsAt: { type: 'instant', filter: ['gte', 'lt', 'between'], sortable: true },
42
+ fee: { type: 'decimal', filter: ['gte', 'lte'], sortable: true },
43
+ },
44
+ defaultSort: [{ field: 'startsAt', direction: 'asc' }],
45
+ tieBreaker: 'id',
46
+ });
47
+
48
+ declare const config: { readonly search: { readonly node: string; readonly username: string; readonly password: string } };
49
+
50
+ export const scope = new AsyncLocalStorageExecutionScope();
51
+
52
+ // infrastructure: the adapter extends the store and adds nothing
53
+ export class SearchAppointmentList extends OpenSearchReadModelStore<AppointmentRow> implements AppointmentList {
54
+ constructor() {
55
+ super({
56
+ transport: fetchTransport({ node: config.search.node, auth: config.search }),
57
+ name: 'scheduling_appointments',
58
+ definition: appointmentCriteria,
59
+ fields: { notes: 'string' }, // kept with the row, neither filtered nor sorted
60
+ tenancy: { strategy: 'attribute', scope }, // or 'index', or { strategy: 'none' }
61
+ });
62
+ }
63
+ }
64
+
65
+ // the platform, once per tenant when it is created (and again at each start: it is idempotent)
66
+ export async function provisionTenant(list: SearchAppointmentList, tenantId: string): Promise<void> {
67
+ await list.provision(tenantId);
68
+ }
69
+ ```
70
+
71
+ A projector writes through the port, as on any store (`@ddd-ts-kit/kernel`, "Projections"):
72
+
73
+ ```ts
74
+ @Projection('scheduling.appointment-list')
75
+ export class AppointmentListProjection {
76
+ constructor(private readonly appointments: AppointmentList) {}
77
+
78
+ @On(AppointmentBooked)
79
+ booked(event: AppointmentBooked) {
80
+ return this.appointments.upsertIfNewer(event.aggregateId, stampOf(event), () => rowOf(event));
81
+ }
82
+
83
+ @On(AppointmentCancelled)
84
+ cancelled(event: AppointmentCancelled) {
85
+ return this.appointments.delete(event.aggregateId, stampOf(event));
86
+ }
87
+ }
88
+ ```
89
+
90
+ The options of `OpenSearchReadModelStore`:
91
+
92
+ | Option | Default | |
93
+ |---|---|---|
94
+ | `transport` | required | `fetchTransport(...)`, or the official client of the project wrapped in an `OpenSearchTransport` |
95
+ | `name` | required | lower case letters, digits and `_`, at most 100: the indices and aliases are built from it |
96
+ | `definition` | required | the `CriteriaDefinition` of the read port; its fields are mapped and indexed |
97
+ | `fields` | none | the other fields of the row with their type (`string`, `number`, `boolean`, `instant`, `decimal`), kept and not indexed |
98
+ | `tenancy` | `{ strategy: 'none' }` | `none`, `index` or `attribute`, with the `scope` the tenant is read from and the tenant `field` (`tenantId`) |
99
+ | `refresh` | none | `'wait_for'`: a write answers once a search sees it |
100
+ | `settings` | none | the settings of an index the store creates: shards, replicas, refresh interval |
101
+
102
+ `fetchTransport` takes `node` (`https://search.internal:9200`), `auth` (`{ username, password }`
103
+ for basic authentication, or `{ authorization }` for the whole header, an `ApiKey` or a bearer
104
+ token) and `timeoutMs` (10 000 by default). It answers every status; it rejects with
105
+ `OpenSearchUnavailableError` only when no answer came. To use the official client:
106
+
107
+ ```ts
108
+ const transport: OpenSearchTransport = {
109
+ async request({ method, path, query, body }) {
110
+ const response = await client.transport.request({ method, path, querystring: query, body }, { ignore: [404, 409] });
111
+
112
+ return { status: response.statusCode ?? 200, body: response.body };
113
+ },
114
+ };
115
+ ```
116
+
117
+ ## Tenancy
118
+
119
+ | Strategy | Indices | A tenant is read and written through | An elevation reads through |
120
+ |---|---|---|---|
121
+ | `none` | `<name>.v1` | the alias `<name>` | |
122
+ | `index` | `<name>-<tenant>.v1`, one per tenant | the alias `<name>-<tenant>`, on that tenant's index | the alias `<name>`, on every tenant's index |
123
+ | `attribute` | `<name>.v1`, shared | the alias `<name>-<tenant>`, filtered on the tenant field and routed by the tenant | the alias `<name>`, on the shared index |
124
+
125
+ Every read and write goes through an alias, never an index, so the store reads the same way under
126
+ both tenant strategies, and the filter of a tenant's alias is applied by OpenSearch itself: a
127
+ query sent through that alias by another program sees that tenant's documents only. The store
128
+ adds the same condition to each of its searches. Under both tenant strategies:
129
+
130
+ - each document holds the tenant of the work in the tenant field (`tenantId` by default), which
131
+ the store writes itself, since a write through a filtered alias does not; when the row has a
132
+ field of that name, it holds the tenant of the work, whatever the row said;
133
+ - a `get` and every write reach the tenant of the work (`tenantScopeOf`): a document of another
134
+ tenant is answered as absent, even under an elevation;
135
+ - a `search` reaches what `tenantReachOf` allows: the tenant of the work, or, under
136
+ `acrossTenants`, every tenant or the tenants it names;
137
+ - work that names no tenant is refused with `NoCurrentTenantError`;
138
+ - under `attribute` a document's id is `<tenant>:<key>`, so two tenants may hold the same key.
139
+
140
+ A tenant becomes part of a name: it is refused with `InvalidIndexNameError` unless it is made of
141
+ lower case letters, digits, `_` and `-` (a tenant id of the kernel may hold upper case letters:
142
+ `Acme` is refused rather than read as `acme`). A read model name holds no `-` and a tenant no `.`,
143
+ so no alias of a tenant is ever the name of an index or the alias of another read model.
144
+
145
+ **Provisioning.** The store never creates an index on a write, where a typo in a name would
146
+ create one: a write and a read through an alias that does not exist are refused with
147
+ `UnprovisionedIndexError`. The platform calls `ensureMapping()` for a read model without tenancy
148
+ and `provision(tenant)` for each tenant; both are idempotent, and add to an existing index the
149
+ fields its mapping lacks (a field mapped with another type is refused by OpenSearch).
150
+
151
+ ## What it does
152
+
153
+ | Port method | On OpenSearch |
154
+ |---|---|
155
+ | `get(key)` | `GET /<alias>/_doc/<id>`; the tenant of the document is checked, since a filtered alias does not filter a get |
156
+ | `upsertIfNewer`, `delete` | the get above, then `PUT /<alias>/_doc/<id>?require_alias=true` with `op_type=create` for a new key, or `if_seq_no` and `if_primary_term` of the document read; on a conflict it reads again, five attempts, then `ConcurrencyError` |
157
+ | `search(scopedCriteria)` | `POST /<alias>/_search`: every operator, group, sort and page of the criteria as filters of the query DSL; the deleted rows left out; an offset page counted exactly (`track_total_hits`) |
158
+ | `ensureMapping()`, `provision(tenant)` | `PUT /<index>`, `PUT /<index>/_mapping`, `POST /_aliases` |
159
+
160
+ The endpoints are the ones Elasticsearch shares, but the store was run on OpenSearch only.
161
+
162
+ **Mapping.** It is `dynamic: 'strict'`: a field of a row that the read model does not declare is
163
+ refused at the write (`OpenSearchRequestError`, `strict_dynamic_mapping_exception`). The fields of
164
+ the definition are indexed: `string` as `keyword` (compared by code point, as the criteria do),
165
+ `number` as `double`, `boolean`, `instant` as `date` to the millisecond. A `decimal` is kept as it
166
+ was written and compared through an order key (`_ddd_order.<field>`), a keyword whose byte order is
167
+ the order of the numbers: no float, no rounding. The stamp and the deletion live in
168
+ `_ddd_stamp` and `_ddd_deleted`; `get` and `search` give back the declared fields only.
169
+
170
+ **Order.** A replace is conditional on the sequence number of the document read: two events of
171
+ one key never overwrite each other blindly, and the stamp rule is the one of the kernel
172
+ (`isNewer`). A deleted row stays as a trace with its stamp: an older event delivered late does not
173
+ bring it back.
174
+
175
+ **Cursor pages** are keyset pages, as on the SQL stores: the position the cursor holds becomes a
176
+ filter (`plan.seek`), not `search_after`, whose values are the engine's (epoch milliseconds,
177
+ order keys) rather than the row's. **Offset pages** use `from` and `size`, bounded by
178
+ `index.max_result_window` (10 000 by default).
179
+
180
+ **Refresh.** A write answers at once, and a search sees it after the next refresh of the index
181
+ (one second by default): the read side is eventually consistent, and `get` reads the document at
182
+ once. `refresh: 'wait_for'` makes each write wait until a search sees it, at the cost of that
183
+ wait on every write; it is what the specs use.
184
+
185
+ ## Limits
186
+
187
+ - **No transaction with the database.** A write to OpenSearch does not commit with the
188
+ processed-event mark of the unit of work, as a write of an SQL store does. A failure between
189
+ the two delivers the event again, and the stamp makes that delivery `stale`: nothing is applied
190
+ twice. A write that succeeded in a unit of work that rolls back is not undone.
191
+ - **No rebuild yet.** `ProjectionRebuild` refuses this store with `UnsupportedRebuildError`. The
192
+ names keep it open: every index carries its generation (`v1`), every read and write goes through
193
+ an alias, so a rebuild fills `v2` and moves the alias in one `_aliases` call.
194
+ - **No full-text search.** A `string` is a `keyword`: `contains` is a wildcard query, case
195
+ sensitive, and slow on a large index. Text analysis, relevance and facets are not built.
196
+ - **A string up to 32 766 bytes** in a filtered field: Lucene refuses a longer term.
197
+ - Offset pages stop at `index.max_result_window`; page by cursor beyond.
198
+
199
+ ## Tests
200
+
201
+ `readModelRowsContract` and `criteriaContract` of `@ddd-ts-kit/testing/contracts` (re-exported by
202
+ `@ddd-ts-kit/opensearch/testing`) under each strategy, and the specs of the tenancy: two tenants,
203
+ each sees and changes only its own documents, a search never returns another tenant's, an
204
+ elevation reads across, work with no tenant and an unprovisioned tenant are refused, and no index
205
+ is created by a write. They run on an OpenSearch in memory, in the process, which serves the
206
+ subset of the REST API the store calls over HTTP, and on the server that
207
+ `DDD_TS_KIT_TEST_OPENSEARCH_URL` names: OpenSearch 3 in the pipeline, with the security plugin
208
+ disabled. `readModelStoreContract`, which adds the rebuild, does not run: there is no rebuild.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A name that would become part of an index or an alias name and that the store refuses: a read
3
+ * model name or a tenant outside lower case letters, digits and `_` (and `-` for a tenant), or too
4
+ * long. Refused, never altered: `Acme` and `acme` would otherwise share one index.
5
+ */
6
+ export declare class InvalidIndexNameError extends Error {
7
+ readonly what: 'read model' | 'tenant';
8
+ readonly named: string;
9
+ readonly code = "INVALID_INDEX_NAME";
10
+ constructor(what: 'read model' | 'tenant', named: string, rule: string);
11
+ }
12
+ //# sourceMappingURL=invalid-index-name-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalid-index-name-error.d.ts","sourceRoot":"","sources":["../../src/errors/invalid-index-name-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAI5C,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAJxB,QAAQ,CAAC,IAAI,wBAAwB;IAErC,YACW,IAAI,EAAE,YAAY,GAAG,QAAQ,EAC7B,KAAK,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,EAIb;CACF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A name that would become part of an index or an alias name and that the store refuses: a read
3
+ * model name or a tenant outside lower case letters, digits and `_` (and `-` for a tenant), or too
4
+ * long. Refused, never altered: `Acme` and `acme` would otherwise share one index.
5
+ */
6
+ export class InvalidIndexNameError extends Error {
7
+ what;
8
+ named;
9
+ code = 'INVALID_INDEX_NAME';
10
+ constructor(what, named, rule) {
11
+ super(`Invalid ${what} name ${JSON.stringify(named.slice(0, 80))} for OpenSearch: ${rule}`);
12
+ this.what = what;
13
+ this.named = named;
14
+ this.name = 'InvalidIndexNameError';
15
+ }
16
+ }
17
+ //# sourceMappingURL=invalid-index-name-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalid-index-name-error.js","sourceRoot":"","sources":["../../src/errors/invalid-index-name-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAInC,IAAI;IACJ,KAAK;IAJP,IAAI,GAAG,oBAAoB,CAAC;IAErC,YACW,IAA6B,EAC7B,KAAa,EACtB,IAAY;QAEZ,KAAK,CAAC,WAAW,IAAI,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;oBAJnF,IAAI;qBACJ,KAAK;QAId,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The node refused a request the store did not expect it to refuse: a document that the strict
3
+ * mapping does not hold, a mapping it cannot change, a cluster that refuses the credentials. The
4
+ * `type` and `reason` are the ones OpenSearch gave; the body of the request is never repeated.
5
+ */
6
+ export declare class OpenSearchRequestError extends Error {
7
+ readonly method: string;
8
+ readonly path: string;
9
+ readonly status: number;
10
+ readonly type: string | undefined;
11
+ readonly code = "OPENSEARCH_REQUEST_REFUSED";
12
+ constructor(method: string, path: string, status: number, type: string | undefined, reason: string | undefined);
13
+ }
14
+ //# sourceMappingURL=open-search-request-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-search-request-error.d.ts","sourceRoot":"","sources":["../../src/errors/open-search-request-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAI7C,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IANnC,QAAQ,CAAC,IAAI,gCAAgC;IAE7C,YACW,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,SAAS,EACjC,MAAM,EAAE,MAAM,GAAG,SAAS,EAO3B;CACF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The node refused a request the store did not expect it to refuse: a document that the strict
3
+ * mapping does not hold, a mapping it cannot change, a cluster that refuses the credentials. The
4
+ * `type` and `reason` are the ones OpenSearch gave; the body of the request is never repeated.
5
+ */
6
+ export class OpenSearchRequestError extends Error {
7
+ method;
8
+ path;
9
+ status;
10
+ type;
11
+ code = 'OPENSEARCH_REQUEST_REFUSED';
12
+ constructor(method, path, status, type, reason) {
13
+ super(`OpenSearch answered ${String(status)} to ${method} ${path}${type === undefined ? '' : `: ${type}`}${reason === undefined ? '' : `, ${reason}`}`);
14
+ this.method = method;
15
+ this.path = path;
16
+ this.status = status;
17
+ this.type = type;
18
+ this.name = 'OpenSearchRequestError';
19
+ }
20
+ }
21
+ //# sourceMappingURL=open-search-request-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-search-request-error.js","sourceRoot":"","sources":["../../src/errors/open-search-request-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAIpC,MAAM;IACN,IAAI;IACJ,MAAM;IACN,IAAI;IANN,IAAI,GAAG,4BAA4B,CAAC;IAE7C,YACW,MAAc,EACd,IAAY,EACZ,MAAc,EACd,IAAwB,EACjC,MAA0B;QAE1B,KAAK,CACH,uBAAuB,MAAM,CAAC,MAAM,CAAC,OAAO,MAAM,IAAI,IAAI,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,EAAE,CACjJ,CAAC;sBARO,MAAM;oBACN,IAAI;sBACJ,MAAM;oBACN,IAAI;QAOb,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ /** No answer came from the node: it cannot be reached, or it took longer than the timeout. */
2
+ export declare class OpenSearchUnavailableError extends Error {
3
+ readonly method: string;
4
+ readonly path: string;
5
+ readonly code = "OPENSEARCH_UNAVAILABLE";
6
+ constructor(method: string, path: string, options: {
7
+ readonly cause: unknown;
8
+ });
9
+ }
10
+ //# sourceMappingURL=open-search-unavailable-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-search-unavailable-error.d.ts","sourceRoot":"","sources":["../../src/errors/open-search-unavailable-error.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,qBAAa,0BAA2B,SAAQ,KAAK;IAIjD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAJvB,QAAQ,CAAC,IAAI,4BAA4B;IAEzC,YACW,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAIrC;CACF"}
@@ -0,0 +1,13 @@
1
+ /** No answer came from the node: it cannot be reached, or it took longer than the timeout. */
2
+ export class OpenSearchUnavailableError extends Error {
3
+ method;
4
+ path;
5
+ code = 'OPENSEARCH_UNAVAILABLE';
6
+ constructor(method, path, options) {
7
+ super(`OpenSearch did not answer ${method} ${path}`, options);
8
+ this.method = method;
9
+ this.path = path;
10
+ this.name = 'OpenSearchUnavailableError';
11
+ }
12
+ }
13
+ //# sourceMappingURL=open-search-unavailable-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-search-unavailable-error.js","sourceRoot":"","sources":["../../src/errors/open-search-unavailable-error.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAIxC,MAAM;IACN,IAAI;IAJN,IAAI,GAAG,wBAAwB,CAAC;IAEzC,YACW,MAAc,EACd,IAAY,EACrB,OAAoC;QAEpC,KAAK,CAAC,6BAA6B,MAAM,IAAI,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;sBAJrD,MAAM;oBACN,IAAI;QAIb,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The alias a read or a write goes through does not exist: the tenant was never provisioned
3
+ * (`provision(tenant)`), or the read model never mapped (`ensureMapping()`). The store never
4
+ * creates an index on a write, where a typo would create one.
5
+ */
6
+ export declare class UnprovisionedIndexError extends Error {
7
+ readonly alias: string;
8
+ readonly code = "UNPROVISIONED_INDEX";
9
+ constructor(alias: string);
10
+ }
11
+ //# sourceMappingURL=unprovisioned-index-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unprovisioned-index-error.d.ts","sourceRoot":"","sources":["../../src/errors/unprovisioned-index-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAGpC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAFlC,QAAQ,CAAC,IAAI,yBAAyB;IAEtC,YAAqB,KAAK,EAAE,MAAM,EAGjC;CACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The alias a read or a write goes through does not exist: the tenant was never provisioned
3
+ * (`provision(tenant)`), or the read model never mapped (`ensureMapping()`). The store never
4
+ * creates an index on a write, where a typo would create one.
5
+ */
6
+ export class UnprovisionedIndexError extends Error {
7
+ alias;
8
+ code = 'UNPROVISIONED_INDEX';
9
+ constructor(alias) {
10
+ super(`The OpenSearch alias "${alias}" does not exist: provision the tenant, or map the read model, first`);
11
+ this.alias = alias;
12
+ this.name = 'UnprovisionedIndexError';
13
+ }
14
+ }
15
+ //# sourceMappingURL=unprovisioned-index-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unprovisioned-index-error.js","sourceRoot":"","sources":["../../src/errors/unprovisioned-index-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAG3B,KAAK;IAFjB,IAAI,GAAG,qBAAqB,CAAC;IAEtC,YAAqB,KAAa;QAChC,KAAK,CAAC,yBAAyB,KAAK,sEAAsE,CAAC,CAAC;qBADzF,KAAK;QAExB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `ProjectionRebuild` was given an OpenSearch read model: its rebuild is not built yet. The names
3
+ * keep it open (each index carries a generation, every read goes through an alias), so a later
4
+ * version fills the next generation and moves the alias in one step.
5
+ */
6
+ export declare class UnsupportedRebuildError extends Error {
7
+ readonly step: string;
8
+ readonly code = "UNSUPPORTED_REBUILD";
9
+ constructor(step: string);
10
+ }
11
+ //# sourceMappingURL=unsupported-rebuild-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported-rebuild-error.d.ts","sourceRoot":"","sources":["../../src/errors/unsupported-rebuild-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAGpC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAFjC,QAAQ,CAAC,IAAI,yBAAyB;IAEtC,YAAqB,IAAI,EAAE,MAAM,EAGhC;CACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `ProjectionRebuild` was given an OpenSearch read model: its rebuild is not built yet. The names
3
+ * keep it open (each index carries a generation, every read goes through an alias), so a later
4
+ * version fills the next generation and moves the alias in one step.
5
+ */
6
+ export class UnsupportedRebuildError extends Error {
7
+ step;
8
+ code = 'UNSUPPORTED_REBUILD';
9
+ constructor(step) {
10
+ super(`The OpenSearch read model has no rebuild yet (${step})`);
11
+ this.step = step;
12
+ this.name = 'UnsupportedRebuildError';
13
+ }
14
+ }
15
+ //# sourceMappingURL=unsupported-rebuild-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported-rebuild-error.js","sourceRoot":"","sources":["../../src/errors/unsupported-rebuild-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAG3B,IAAI;IAFhB,IAAI,GAAG,qBAAqB,CAAC;IAEtC,YAAqB,IAAY;QAC/B,KAAK,CAAC,iDAAiD,IAAI,GAAG,CAAC,CAAC;oBAD7C,IAAI;QAEvB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}