better-auth-elasticsearch 0.2.0 → 0.3.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/src/migrate.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { MigratedIndex } from "./index-layout.js";
2
+ import type { DuplicateValues } from "./unique-reservations.js";
2
3
 
3
4
  /** What migrate() did to one model whose mapping had changed. */
4
5
  export interface MigratedModel extends MigratedIndex {
@@ -30,6 +31,12 @@ export interface MigrateOptions {
30
31
  export interface MigrationResult {
31
32
  /** The models that moved to a new index; models already matching are left out. */
32
33
  migrated: MigratedModel[];
34
+ /**
35
+ * Values of unique fields that more than one row already holds, one entry
36
+ * per value, naming the rows but not the value. Such rows were written
37
+ * before the adapter enforced the field; resolve them by hand.
38
+ */
39
+ duplicates: DuplicateValues[];
33
40
  }
34
41
 
35
42
  /** Where the adapter hands migrate() the code that knows its indices. */
@@ -50,6 +57,10 @@ export interface AuthWithContext {
50
57
  * database is `elasticsearchAdapter(...)`. Reads carry on throughout; writes
51
58
  * to a model being moved wait until it is done (see `writeBlockTimeoutMs`).
52
59
  * Models already matching are left alone, so running it again is safe.
60
+ *
61
+ * Then reserves the values of unique fields for rows that hold no
62
+ * reservation yet, such as rows written before the adapter enforced them,
63
+ * and reports values more than one row holds.
53
64
  */
54
65
  export const migrate = async (
55
66
  auth: AuthWithContext,