@better-auth/test-utils 1.7.12 → 1.7.13

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.
@@ -1,27 +1,23 @@
1
- import * as _$better_auth0 from "better-auth";
2
- import * as _$_better_auth_test_utils_adapter0 from "@better-auth/test-utils/adapter";
3
-
4
1
  //#region src/adapter/suites/case-insensitive.d.ts
5
2
  /**
6
3
  * Test suite for case-insensitive string operations across adapters.
7
4
  * Tests eq, ne, in, not_in, contains, starts_with, ends_with with mode: "insensitive".
8
5
  */
9
- declare const caseInsensitiveTestSuite: (options?: {
6
+ export declare const caseInsensitiveTestSuite: (options?: {
10
7
  disableTests?: Partial<Record<"findOne - eq with mode insensitive should match regardless of case" | "findOne - eq with mode sensitive (default) should not match different case" | "findMany - eq with mode insensitive" | "findMany - ne with mode insensitive" | "findMany - in with mode insensitive" | "findMany - not_in with mode insensitive" | "findMany - contains with mode insensitive" | "findMany - starts_with with mode insensitive" | "findMany - ends_with with mode insensitive" | "count - with mode insensitive" | "update - where with mode insensitive" | "deleteMany - where with mode insensitive", boolean> & {
11
8
  ALL?: boolean;
12
9
  }> | undefined;
13
10
  } | undefined) => (helpers: {
14
- adapter: () => Promise<_$better_auth0.DBAdapter<_$better_auth0.BetterAuthOptions>>;
15
- log: _$_better_auth_test_utils_adapter0.Logger;
11
+ adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
12
+ log: import("@better-auth/test-utils/adapter").Logger;
16
13
  adapterDisplayName: string;
17
- getBetterAuthOptions: () => _$better_auth0.BetterAuthOptions;
18
- modifyBetterAuthOptions: (options: _$better_auth0.BetterAuthOptions) => Promise<_$better_auth0.BetterAuthOptions>;
14
+ getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
15
+ modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
19
16
  cleanup: () => Promise<void>;
20
17
  runMigrations: () => Promise<void>;
21
18
  prefixTests?: string | undefined;
22
- onTestFinish: (stats: _$_better_auth_test_utils_adapter0.TestSuiteStats) => Promise<void>;
19
+ onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
23
20
  customIdGenerator?: (() => any | Promise<any> | undefined) | undefined;
24
21
  transformIdOutput?: ((id: any) => string | undefined) | undefined;
25
22
  }) => Promise<void>;
26
- //#endregion
27
- export { caseInsensitiveTestSuite };
23
+ //#endregion
@@ -41,7 +41,7 @@ const caseInsensitiveTestSuite = createTestSuite("case-insensitive", {}, (helper
41
41
  },
42
42
  forceAllowId: true
43
43
  });
44
- expect(await adapter.findOne({
44
+ const result = await adapter.findOne({
45
45
  model: "user",
46
46
  where: [{
47
47
  field: "email",
@@ -49,7 +49,8 @@ const caseInsensitiveTestSuite = createTestSuite("case-insensitive", {}, (helper
49
49
  operator: "eq",
50
50
  mode: "sensitive"
51
51
  }]
52
- })).toBeNull();
52
+ });
53
+ expect(result).toBeNull();
53
54
  },
54
55
  "findMany - eq with mode insensitive": async () => {
55
56
  const user = await adapter.create({
@@ -222,7 +223,7 @@ const caseInsensitiveTestSuite = createTestSuite("case-insensitive", {}, (helper
222
223
  },
223
224
  forceAllowId: true
224
225
  });
225
- expect(await adapter.count({
226
+ const result = await adapter.count({
226
227
  model: "user",
227
228
  where: [{
228
229
  field: "email",
@@ -230,7 +231,8 @@ const caseInsensitiveTestSuite = createTestSuite("case-insensitive", {}, (helper
230
231
  operator: "eq",
231
232
  mode: "insensitive"
232
233
  }]
233
- })).toBeGreaterThanOrEqual(1);
234
+ });
235
+ expect(result).toBeGreaterThanOrEqual(1);
234
236
  },
235
237
  "update - where with mode insensitive": async () => {
236
238
  const user = await adapter.create({
@@ -276,20 +278,22 @@ const caseInsensitiveTestSuite = createTestSuite("case-insensitive", {}, (helper
276
278
  mode: "insensitive"
277
279
  }]
278
280
  });
279
- expect(await adapter.findOne({
281
+ const deleted = await adapter.findOne({
280
282
  model: "user",
281
283
  where: [{
282
284
  field: "id",
283
285
  value: deleteUser.id
284
286
  }]
285
- })).toBeNull();
286
- expect(await adapter.findOne({
287
+ });
288
+ expect(deleted).toBeNull();
289
+ const kept = await adapter.findOne({
287
290
  model: "user",
288
291
  where: [{
289
292
  field: "id",
290
293
  value: keepUser.id
291
294
  }]
292
- })).not.toBeNull();
295
+ });
296
+ expect(kept).not.toBeNull();
293
297
  }
294
298
  };
295
299
  });
@@ -4,4 +4,5 @@ import { caseInsensitiveTestSuite } from "./case-insensitive.mjs";
4
4
  import { joinsTestSuite } from "./joins.mjs";
5
5
  import { numberIdTestSuite } from "./number-id.mjs";
6
6
  import { transactionsTestSuite } from "./transactions.mjs";
7
- import { uuidTestSuite } from "./uuid.mjs";
7
+ import { uuidTestSuite } from "./uuid.mjs";
8
+ export { authFlowTestSuite, caseInsensitiveTestSuite, enableJoinTests, getNormalTestSuiteTests, joinsTestSuite, normalTestSuite, numberIdTestSuite, transactionsTestSuite, uuidTestSuite };
@@ -1,18 +1,17 @@
1
1
  import { Logger } from "../test-adapter.mjs";
2
2
  import { TestSuiteStats } from "../create-test-suite.mjs";
3
- import * as _$better_auth0 from "better-auth";
4
-
3
+ import "../../adapter.mjs";
5
4
  //#region src/adapter/suites/joins.d.ts
6
- declare const joinsTestSuite: (options?: {
5
+ export declare const joinsTestSuite: (options?: {
7
6
  disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "create - should return null for nullable foreign keys" | "create - should apply default values to fields" | "findOne - should find a model" | "findOne - should not apply defaultValue if value not found" | "findOne - should find a model using a reference field" | "findOne - should not throw on record not found" | "findOne - should find a model without id" | "findOne - should find a model with join" | "findOne - should find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should find a model with additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with one-to-one join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an object for one-to-one joins" | "findOne - should return an array for one-to-many joins" | "findOne - should work with both one-to-one and one-to-many joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should join a model with modified field name" | "findMany - should find many models" | "findMany - should find many models with date fields" | "findMany - should find many models with join" | "findMany - should find many with join and limit" | "findMany - should select fields" | "findMany - should select fields with one-to-many join" | "findMany - should select fields with one-to-one join" | "findMany - should select fields with multiple joins" | "findMany - should find many with join and offset" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should return an empty array when no models are found" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should find many models with starts_with operator" | "findMany - starts_with should not interpret regex patterns" | "findMany - ends_with should not interpret regex patterns" | "findMany - contains should not interpret regex patterns" | "findMany - should find many models with ends_with operator" | "findMany - should find many models with contains operator" | "findMany - should handle multiple where conditions with different operators" | "findMany - should find many models with contains operator (using symbol)" | "findMany - should find many models with eq operator" | "findMany - should find many models with ne operator" | "findMany - should find many models with gt operator" | "findMany - should find many models with gte operator" | "findMany - should find many models with lte operator" | "findMany - should find many models with lt operator" | "findMany - should find many models with in operator" | "findMany - should find many models with not_in operator" | "findMany - should find many models with sortBy" | "findMany - should find many models with sortBy id" | "findMany - should find many models with limit" | "findMany - should find many models with offset" | "findMany - should find many models with limit and offset" | "findMany - should find many models with sortBy and offset" | "findMany - should find many models with sortBy and limit" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "update - should update a model" | "update - should return null when where is empty" | "updateMany - should update all models when where is empty" | "updateMany - should update many models with a specific where" | "updateMany - should update many models with a multiple where" | "incrementOne - guarded set transition returns the row on a matching guard and null on a guard miss" | "delete - should delete a model" | "delete - should not throw on record not found" | "delete - should delete by non-unique field" | "deleteMany - should delete many models" | "deleteMany - starts_with should not interpret regex patterns" | "deleteMany - ends_with should not interpret regex patterns" | "deleteMany - contains should not interpret regex patterns" | "deleteMany - should delete many models with numeric values" | "deleteMany - should delete many models with boolean values" | "count - should count many models" | "count - should return 0 with no rows to count" | "count - should count with where clause" | "update - should correctly return record when updating a field used in where clause" | "update - should handle updating multiple fields including where clause field" | "update - should work when updated field is not in where clause" | "findOne - backwards join should only return single record not array" | "findMany - backwards join should only return single record not array" | "findOne - backwards join with modified field name (session base, users-table join)" | "findOne - multiple joins should return result even when some joined tables have no matching rows" | "findOne - should be able to perform a limited join" | "findOne - should be able to perform a complex limited join" | "findMany - should be able to perform a limited join" | "findMany - should be able to perform a complex limited join" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should return empty array for one-to-many join when joined records don't exist" | "findMany - should handle mixed joins correctly when some are missing" | "create - should support arrays" | "create - should support json" | "update - should support multiple where conditions under AND connector with unique field" | "findMany - eq operator with null value (single condition) should use IS NULL" | "findMany - eq and ne operators with null value in AND group should use IS NULL / IS NOT NULL" | "findMany - eq and ne operators with null value in OR group should use IS NULL / IS NOT NULL" | "update - should return updated record when where condition uses null value" | "update - should return null when a multi-predicate where matches no row", boolean> & {
8
7
  ALL?: boolean;
9
8
  }> | undefined;
10
9
  } | undefined) => (helpers: {
11
- adapter: () => Promise<_$better_auth0.DBAdapter<_$better_auth0.BetterAuthOptions>>;
10
+ adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
12
11
  log: Logger;
13
12
  adapterDisplayName: string;
14
- getBetterAuthOptions: () => _$better_auth0.BetterAuthOptions;
15
- modifyBetterAuthOptions: (options: _$better_auth0.BetterAuthOptions) => Promise<_$better_auth0.BetterAuthOptions>;
13
+ getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
14
+ modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
16
15
  cleanup: () => Promise<void>;
17
16
  runMigrations: () => Promise<void>;
18
17
  prefixTests?: string | undefined;
@@ -20,5 +19,4 @@ declare const joinsTestSuite: (options?: {
20
19
  customIdGenerator?: (() => any | Promise<any> | undefined) | undefined;
21
20
  transformIdOutput?: ((id: any) => string | undefined) | undefined;
22
21
  }) => Promise<void>;
23
- //#endregion
24
- export { joinsTestSuite };
22
+ //#endregion
@@ -10,7 +10,8 @@ const joinsTestSuite = createTestSuite("joins", {
10
10
  const { "create - should use generateId if provided": _, ...normalTests } = getNormalTestSuiteTests({ ...helpers });
11
11
  return {
12
12
  "init - tests": async () => {
13
- expect(helpers.getBetterAuthOptions().advanced?.database?.joins).toBe(true);
13
+ const opts = helpers.getBetterAuthOptions();
14
+ expect(opts.advanced?.database?.joins).toBe(true);
14
15
  },
15
16
  ...normalTests
16
17
  };
@@ -1,18 +1,17 @@
1
1
  import { Logger } from "../test-adapter.mjs";
2
2
  import { TestSuiteStats } from "../create-test-suite.mjs";
3
- import * as _$better_auth0 from "better-auth";
4
-
3
+ import "../../adapter.mjs";
5
4
  //#region src/adapter/suites/number-id.d.ts
6
- declare const numberIdTestSuite: (options?: {
5
+ export declare const numberIdTestSuite: (options?: {
7
6
  disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "create - should return null for nullable foreign keys" | "create - should apply default values to fields" | "findOne - should find a model" | "findOne - should not apply defaultValue if value not found" | "findOne - should find a model using a reference field" | "findOne - should not throw on record not found" | "findOne - should find a model without id" | "findOne - should find a model with join" | "findOne - should find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should find a model with additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with one-to-one join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an object for one-to-one joins" | "findOne - should return an array for one-to-many joins" | "findOne - should work with both one-to-one and one-to-many joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should join a model with modified field name" | "findMany - should find many models" | "findMany - should find many models with date fields" | "findMany - should find many models with join" | "findMany - should find many with join and limit" | "findMany - should select fields" | "findMany - should select fields with one-to-many join" | "findMany - should select fields with one-to-one join" | "findMany - should select fields with multiple joins" | "findMany - should find many with join and offset" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should return an empty array when no models are found" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should find many models with starts_with operator" | "findMany - starts_with should not interpret regex patterns" | "findMany - ends_with should not interpret regex patterns" | "findMany - contains should not interpret regex patterns" | "findMany - should find many models with ends_with operator" | "findMany - should find many models with contains operator" | "findMany - should handle multiple where conditions with different operators" | "findMany - should find many models with contains operator (using symbol)" | "findMany - should find many models with eq operator" | "findMany - should find many models with ne operator" | "findMany - should find many models with gt operator" | "findMany - should find many models with gte operator" | "findMany - should find many models with lte operator" | "findMany - should find many models with lt operator" | "findMany - should find many models with in operator" | "findMany - should find many models with not_in operator" | "findMany - should find many models with sortBy" | "findMany - should find many models with sortBy id" | "findMany - should find many models with limit" | "findMany - should find many models with offset" | "findMany - should find many models with limit and offset" | "findMany - should find many models with sortBy and offset" | "findMany - should find many models with sortBy and limit" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "update - should update a model" | "update - should return null when where is empty" | "updateMany - should update all models when where is empty" | "updateMany - should update many models with a specific where" | "updateMany - should update many models with a multiple where" | "incrementOne - guarded set transition returns the row on a matching guard and null on a guard miss" | "delete - should delete a model" | "delete - should not throw on record not found" | "delete - should delete by non-unique field" | "deleteMany - should delete many models" | "deleteMany - starts_with should not interpret regex patterns" | "deleteMany - ends_with should not interpret regex patterns" | "deleteMany - contains should not interpret regex patterns" | "deleteMany - should delete many models with numeric values" | "deleteMany - should delete many models with boolean values" | "count - should count many models" | "count - should return 0 with no rows to count" | "count - should count with where clause" | "update - should correctly return record when updating a field used in where clause" | "update - should handle updating multiple fields including where clause field" | "update - should work when updated field is not in where clause" | "findOne - backwards join should only return single record not array" | "findMany - backwards join should only return single record not array" | "findOne - backwards join with modified field name (session base, users-table join)" | "findOne - multiple joins should return result even when some joined tables have no matching rows" | "findOne - should be able to perform a limited join" | "findOne - should be able to perform a complex limited join" | "findMany - should be able to perform a limited join" | "findMany - should be able to perform a complex limited join" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should return empty array for one-to-many join when joined records don't exist" | "findMany - should handle mixed joins correctly when some are missing" | "create - should support arrays" | "create - should support json" | "update - should support multiple where conditions under AND connector with unique field" | "findMany - eq operator with null value (single condition) should use IS NULL" | "findMany - eq and ne operators with null value in AND group should use IS NULL / IS NOT NULL" | "findMany - eq and ne operators with null value in OR group should use IS NULL / IS NOT NULL" | "update - should return updated record when where condition uses null value" | "update - should return null when a multi-predicate where matches no row" | "create - should return a number id", boolean> & {
8
7
  ALL?: boolean;
9
8
  }> | undefined;
10
9
  } | undefined) => (helpers: {
11
- adapter: () => Promise<_$better_auth0.DBAdapter<_$better_auth0.BetterAuthOptions>>;
10
+ adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
12
11
  log: Logger;
13
12
  adapterDisplayName: string;
14
- getBetterAuthOptions: () => _$better_auth0.BetterAuthOptions;
15
- modifyBetterAuthOptions: (options: _$better_auth0.BetterAuthOptions) => Promise<_$better_auth0.BetterAuthOptions>;
13
+ getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
14
+ modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
16
15
  cleanup: () => Promise<void>;
17
16
  runMigrations: () => Promise<void>;
18
17
  prefixTests?: string | undefined;
@@ -20,5 +19,4 @@ declare const numberIdTestSuite: (options?: {
20
19
  customIdGenerator?: (() => any | Promise<any> | undefined) | undefined;
21
20
  transformIdOutput?: ((id: any) => string | undefined) | undefined;
22
21
  }) => Promise<void>;
23
- //#endregion
24
- export { numberIdTestSuite };
22
+ //#endregion
@@ -10,7 +10,8 @@ const numberIdTestSuite = createTestSuite("number-id", {
10
10
  const { "create - should use generateId if provided": _, ...normalTests } = getNormalTestSuiteTests({ ...helpers });
11
11
  return {
12
12
  "init - tests": async () => {
13
- expect(helpers.getBetterAuthOptions().advanced?.database?.generateId === "serial").toBe(true);
13
+ const opts = helpers.getBetterAuthOptions();
14
+ expect(opts.advanced?.database?.generateId === "serial").toBe(true);
14
15
  },
15
16
  "create - should return a number id": async () => {
16
17
  const user = await helpers.generate("user");
@@ -1,21 +1,20 @@
1
1
  import { Logger } from "../test-adapter.mjs";
2
2
  import { TestSuiteStats } from "../create-test-suite.mjs";
3
- import * as _$better_auth0 from "better-auth";
4
-
3
+ import "../../adapter.mjs";
5
4
  //#region src/adapter/suites/transactions.d.ts
6
5
  /**
7
6
  * This test suite tests the transaction functionality of the adapter.
8
7
  */
9
- declare const transactionsTestSuite: (options?: {
8
+ export declare const transactionsTestSuite: (options?: {
10
9
  disableTests?: Partial<Record<"transaction - should rollback failing transaction", boolean> & {
11
10
  ALL?: boolean;
12
11
  }> | undefined;
13
12
  } | undefined) => (helpers: {
14
- adapter: () => Promise<_$better_auth0.DBAdapter<_$better_auth0.BetterAuthOptions>>;
13
+ adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
15
14
  log: Logger;
16
15
  adapterDisplayName: string;
17
- getBetterAuthOptions: () => _$better_auth0.BetterAuthOptions;
18
- modifyBetterAuthOptions: (options: _$better_auth0.BetterAuthOptions) => Promise<_$better_auth0.BetterAuthOptions>;
16
+ getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
17
+ modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
19
18
  cleanup: () => Promise<void>;
20
19
  runMigrations: () => Promise<void>;
21
20
  prefixTests?: string | undefined;
@@ -23,5 +22,4 @@ declare const transactionsTestSuite: (options?: {
23
22
  customIdGenerator?: (() => any | Promise<any> | undefined) | undefined;
24
23
  transformIdOutput?: ((id: any) => string | undefined) | undefined;
25
24
  }) => Promise<void>;
26
- //#endregion
27
- export { transactionsTestSuite };
25
+ //#endregion
@@ -17,7 +17,8 @@ const transactionsTestSuite = createTestSuite("transactions", {}, ({ adapter, ge
17
17
  data: user1,
18
18
  forceAllowId: true
19
19
  });
20
- expect(await tx.findMany({ model: "user" })).toHaveLength(1);
20
+ const users = await tx.findMany({ model: "user" });
21
+ expect(users).toHaveLength(1);
21
22
  throw new Error("Simulated failure");
22
23
  })).rejects.toThrow("Simulated failure");
23
24
  const result = await adapter.findMany({ model: "user" });
@@ -1,18 +1,17 @@
1
1
  import { Logger } from "../test-adapter.mjs";
2
2
  import { TestSuiteStats } from "../create-test-suite.mjs";
3
- import * as _$better_auth0 from "better-auth";
4
-
3
+ import "../../adapter.mjs";
5
4
  //#region src/adapter/suites/uuid.d.ts
6
- declare const uuidTestSuite: (options?: {
5
+ export declare const uuidTestSuite: (options?: {
7
6
  disableTests?: Partial<Record<"init - tests" | "create - should create a model" | "create - should always return an id" | "create - should return null for nullable foreign keys" | "create - should apply default values to fields" | "findOne - should find a model" | "findOne - should not apply defaultValue if value not found" | "findOne - should find a model using a reference field" | "findOne - should not throw on record not found" | "findOne - should find a model without id" | "findOne - should find a model with join" | "findOne - should find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should find a model with additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with one-to-one join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an object for one-to-one joins" | "findOne - should return an array for one-to-many joins" | "findOne - should work with both one-to-one and one-to-many joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should join a model with modified field name" | "findMany - should find many models" | "findMany - should find many models with date fields" | "findMany - should find many models with join" | "findMany - should find many with join and limit" | "findMany - should select fields" | "findMany - should select fields with one-to-many join" | "findMany - should select fields with one-to-one join" | "findMany - should select fields with multiple joins" | "findMany - should find many with join and offset" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should return an empty array when no models are found" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should find many models with starts_with operator" | "findMany - starts_with should not interpret regex patterns" | "findMany - ends_with should not interpret regex patterns" | "findMany - contains should not interpret regex patterns" | "findMany - should find many models with ends_with operator" | "findMany - should find many models with contains operator" | "findMany - should handle multiple where conditions with different operators" | "findMany - should find many models with contains operator (using symbol)" | "findMany - should find many models with eq operator" | "findMany - should find many models with ne operator" | "findMany - should find many models with gt operator" | "findMany - should find many models with gte operator" | "findMany - should find many models with lte operator" | "findMany - should find many models with lt operator" | "findMany - should find many models with in operator" | "findMany - should find many models with not_in operator" | "findMany - should find many models with sortBy" | "findMany - should find many models with sortBy id" | "findMany - should find many models with limit" | "findMany - should find many models with offset" | "findMany - should find many models with limit and offset" | "findMany - should find many models with sortBy and offset" | "findMany - should find many models with sortBy and limit" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "update - should update a model" | "update - should return null when where is empty" | "updateMany - should update all models when where is empty" | "updateMany - should update many models with a specific where" | "updateMany - should update many models with a multiple where" | "incrementOne - guarded set transition returns the row on a matching guard and null on a guard miss" | "delete - should delete a model" | "delete - should not throw on record not found" | "delete - should delete by non-unique field" | "deleteMany - should delete many models" | "deleteMany - starts_with should not interpret regex patterns" | "deleteMany - ends_with should not interpret regex patterns" | "deleteMany - contains should not interpret regex patterns" | "deleteMany - should delete many models with numeric values" | "deleteMany - should delete many models with boolean values" | "count - should count many models" | "count - should return 0 with no rows to count" | "count - should count with where clause" | "update - should correctly return record when updating a field used in where clause" | "update - should handle updating multiple fields including where clause field" | "update - should work when updated field is not in where clause" | "findOne - backwards join should only return single record not array" | "findMany - backwards join should only return single record not array" | "findOne - backwards join with modified field name (session base, users-table join)" | "findOne - multiple joins should return result even when some joined tables have no matching rows" | "findOne - should be able to perform a limited join" | "findOne - should be able to perform a complex limited join" | "findMany - should be able to perform a limited join" | "findMany - should be able to perform a complex limited join" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should return empty array for one-to-many join when joined records don't exist" | "findMany - should handle mixed joins correctly when some are missing" | "create - should support arrays" | "create - should support json" | "update - should support multiple where conditions under AND connector with unique field" | "findMany - eq operator with null value (single condition) should use IS NULL" | "findMany - eq and ne operators with null value in AND group should use IS NULL / IS NOT NULL" | "findMany - eq and ne operators with null value in OR group should use IS NULL / IS NOT NULL" | "update - should return updated record when where condition uses null value" | "update - should return null when a multi-predicate where matches no row" | "create - should return a uuid" | "findOne - should find a model using a uuid" | "create - should keep a deterministic id", boolean> & {
8
7
  ALL?: boolean;
9
8
  }> | undefined;
10
9
  } | undefined) => (helpers: {
11
- adapter: () => Promise<_$better_auth0.DBAdapter<_$better_auth0.BetterAuthOptions>>;
10
+ adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
12
11
  log: Logger;
13
12
  adapterDisplayName: string;
14
- getBetterAuthOptions: () => _$better_auth0.BetterAuthOptions;
15
- modifyBetterAuthOptions: (options: _$better_auth0.BetterAuthOptions) => Promise<_$better_auth0.BetterAuthOptions>;
13
+ getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
14
+ modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
16
15
  cleanup: () => Promise<void>;
17
16
  runMigrations: () => Promise<void>;
18
17
  prefixTests?: string | undefined;
@@ -20,5 +19,4 @@ declare const uuidTestSuite: (options?: {
20
19
  customIdGenerator?: (() => any | Promise<any> | undefined) | undefined;
21
20
  transformIdOutput?: ((id: any) => string | undefined) | undefined;
22
21
  }) => Promise<void>;
23
- //#endregion
24
- export { uuidTestSuite };
22
+ //#endregion
@@ -14,7 +14,8 @@ const uuidTestSuite = createTestSuite("uuid", {
14
14
  const { "create - should use generateId if provided": _, ...normalTests } = getNormalTestSuiteTests(helpers);
15
15
  return {
16
16
  "init - tests": async () => {
17
- expect(helpers.getBetterAuthOptions().advanced?.database?.generateId === "uuid").toBe(true);
17
+ const opts = helpers.getBetterAuthOptions();
18
+ expect(opts.advanced?.database?.generateId === "uuid").toBe(true);
18
19
  },
19
20
  "create - should return a uuid": async () => {
20
21
  const user = await helpers.generate("user");
@@ -50,7 +51,7 @@ const uuidTestSuite = createTestSuite("uuid", {
50
51
  * @see https://github.com/better-auth/better-auth/issues/10624
51
52
  */
52
53
  "create - should keep a deterministic id": async () => {
53
- const id = encodeDeterministicId(crypto.getRandomValues(new Uint8Array(32)), helpers.getBetterAuthOptions());
54
+ const id = encodeDeterministicId(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)), helpers.getBetterAuthOptions());
54
55
  const marker = {
55
56
  id,
56
57
  identifier: `deterministic-id:${id}`,
@@ -59,18 +60,20 @@ const uuidTestSuite = createTestSuite("uuid", {
59
60
  createdAt: /* @__PURE__ */ new Date(),
60
61
  updatedAt: /* @__PURE__ */ new Date()
61
62
  };
62
- expect((await helpers.adapter.create({
63
+ const created = await helpers.adapter.create({
63
64
  model: "verification",
64
65
  data: marker,
65
66
  forceAllowId: true
66
- })).id).toBe(id);
67
- expect((await helpers.adapter.findOne({
67
+ });
68
+ expect(created.id).toBe(id);
69
+ const found = await helpers.adapter.findOne({
68
70
  model: "verification",
69
71
  where: [{
70
72
  field: "id",
71
73
  value: id
72
74
  }]
73
- }))?.id).toBe(id);
75
+ });
76
+ expect(found?.id).toBe(id);
74
77
  },
75
78
  ...normalTests
76
79
  };
@@ -1,26 +1,15 @@
1
1
  import { createTestSuite } from "./create-test-suite.mjs";
2
2
  import { DBAdapter } from "@better-auth/core/db/adapter";
3
3
  import { Awaitable, BetterAuthOptions } from "@better-auth/core";
4
-
5
4
  //#region src/adapter/test-adapter.d.ts
6
- type Logger = {
5
+ export type Logger = {
7
6
  info: (...args: any[]) => void;
8
7
  success: (...args: any[]) => void;
9
8
  warn: (...args: any[]) => void;
10
9
  error: (...args: any[]) => void;
11
10
  debug: (...args: any[]) => void;
12
11
  };
13
- declare const testAdapter: ({
14
- adapter: getAdapter,
15
- runMigrations,
16
- overrideBetterAuthOptions,
17
- additionalCleanups,
18
- tests,
19
- prefixTests,
20
- onFinish,
21
- customIdGenerator,
22
- transformIdOutput
23
- }: {
12
+ export declare const testAdapter: ({ adapter: getAdapter, runMigrations, overrideBetterAuthOptions, additionalCleanups, tests, prefixTests, onFinish, customIdGenerator, transformIdOutput }: {
24
13
  /**
25
14
  * A function that will return the adapter instance to test with.
26
15
  *
@@ -71,5 +60,4 @@ declare const testAdapter: ({
71
60
  }) => Promise<{
72
61
  execute: () => void;
73
62
  }>;
74
- //#endregion
75
- export { Logger, testAdapter };
63
+ //#endregion
@@ -5,10 +5,12 @@ import { getAuthTables } from "better-auth/db";
5
5
  //#region src/adapter/test-adapter.ts
6
6
  const testAdapter = async ({ adapter: getAdapter, runMigrations, overrideBetterAuthOptions, additionalCleanups, tests, prefixTests, onFinish, customIdGenerator, transformIdOutput }) => {
7
7
  const defaultBAOptions = {};
8
- let betterAuthOptions = {
9
- ...defaultBAOptions,
10
- ...overrideBetterAuthOptions?.(defaultBAOptions) || {}
11
- };
8
+ let betterAuthOptions = (() => {
9
+ return {
10
+ ...defaultBAOptions,
11
+ ...overrideBetterAuthOptions?.(defaultBAOptions) || {}
12
+ };
13
+ })();
12
14
  let adapter = (await getAdapter(betterAuthOptions))(betterAuthOptions);
13
15
  const adapterName = adapter.options?.adapterConfig.adapterName;
14
16
  const adapterId = adapter.options?.adapterConfig.adapterId || adapter.id;
@@ -19,13 +21,15 @@ const testAdapter = async ({ adapter: getAdapter, runMigrations, overrideBetterA
19
21
  /**
20
22
  * A helper function to log to the console.
21
23
  */
22
- const log = {
23
- info: (...args) => console.log(`${TTY_COLORS.fg.blue}INFO ${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args),
24
- success: (...args) => console.log(`${TTY_COLORS.fg.green}SUCCESS${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args),
25
- warn: (...args) => console.log(`${TTY_COLORS.fg.yellow}WARN ${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args),
26
- error: (...args) => console.log(`${TTY_COLORS.fg.red}ERROR ${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args),
27
- debug: (...args) => console.log(`${TTY_COLORS.fg.magenta}DEBUG ${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args)
28
- };
24
+ const log = (() => {
25
+ return {
26
+ info: (...args) => console.log(`${TTY_COLORS.fg.blue}INFO ${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args),
27
+ success: (...args) => console.log(`${TTY_COLORS.fg.green}SUCCESS${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args),
28
+ warn: (...args) => console.log(`${TTY_COLORS.fg.yellow}WARN ${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args),
29
+ error: (...args) => console.log(`${TTY_COLORS.fg.red}ERROR ${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args),
30
+ debug: (...args) => console.log(`${TTY_COLORS.fg.magenta}DEBUG ${TTY_COLORS.reset} [${adapterDisplayName}]`, ...args)
31
+ };
32
+ })();
29
33
  /**
30
34
  * Cleanup function to remove all rows from the database.
31
35
  */
@@ -7,4 +7,5 @@ import { joinsTestSuite } from "./adapter/suites/joins.mjs";
7
7
  import { numberIdTestSuite } from "./adapter/suites/number-id.mjs";
8
8
  import { transactionsTestSuite } from "./adapter/suites/transactions.mjs";
9
9
  import { uuidTestSuite } from "./adapter/suites/uuid.mjs";
10
+ import "./adapter/suites/index.mjs";
10
11
  export { type InsertRandomFn, type Logger, type TestEntry, type TestSuiteStats, authFlowTestSuite, caseInsensitiveTestSuite, createTestSuite, enableJoinTests, getNormalTestSuiteTests, joinsTestSuite, normalTestSuite, numberIdTestSuite, testAdapter, transactionsTestSuite, uuidTestSuite };
package/dist/scim.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  //#region src/scim-lifecycle.d.ts
2
2
  /** Observable lifecycle boundaries for database and application-state oracles. */
3
- type SCIMLifecycleCheckpoint = "group-created" | "failed-add-rolled-back" | "member-added" | "okta-member-removed" | "entra-member-removed" | "member-restored" | "user-deactivated" | "user-reactivated" | "populated-user-deleted" | "user-reprovisioned" | "reprovisioned-member-added" | "populated-group-deleted" | "lifecycle-complete";
3
+ export type SCIMLifecycleCheckpoint = "group-created" | "failed-add-rolled-back" | "member-added" | "okta-member-removed" | "entra-member-removed" | "member-restored" | "user-deactivated" | "user-reactivated" | "populated-user-deleted" | "user-reprovisioned" | "reprovisioned-member-added" | "populated-group-deleted" | "lifecycle-complete";
4
4
  /** Input for the reusable SCIM black-box lifecycle contract. */
5
- interface SCIMLifecycleOptions {
5
+ export interface SCIMLifecycleOptions {
6
6
  /** Better Auth origin exposed by a real HTTP listener. */
7
7
  baseURL: string;
8
8
  /** Bearer credential for the SCIM connection under test. */
@@ -18,7 +18,7 @@ interface SCIMLifecycleOptions {
18
18
  onCheckpoint?: (checkpoint: SCIMLifecycleCheckpoint) => void | Promise<void>;
19
19
  }
20
20
  /** Identifiers created and deleted by a completed SCIM lifecycle. */
21
- interface SCIMLifecycleResult {
21
+ export interface SCIMLifecycleResult {
22
22
  userId: string;
23
23
  groupId: string;
24
24
  reprovisionedUserId: string;
@@ -29,6 +29,5 @@ interface SCIMLifecycleResult {
29
29
  * Executes one provider-shaped SCIM User and Group lifecycle exclusively over
30
30
  * HTTP. The runner has no access to Better Auth APIs or database internals.
31
31
  */
32
- declare function runSCIMLifecycle(options: SCIMLifecycleOptions): Promise<SCIMLifecycleResult>;
33
- //#endregion
34
- export { SCIMLifecycleCheckpoint, SCIMLifecycleOptions, SCIMLifecycleResult, runSCIMLifecycle };
32
+ export declare function runSCIMLifecycle(options: SCIMLifecycleOptions): Promise<SCIMLifecycleResult>;
33
+ //#endregion
package/dist/scim.mjs CHANGED
@@ -80,7 +80,8 @@ async function runSCIMLifecycle(options) {
80
80
  expect(unauthorized.headers.get("www-authenticate")).toBe("Bearer realm=\"SCIM\"");
81
81
  const discoveryResponse = await fetch(`${scimBaseURL}/ServiceProviderConfig`, { headers: { accept: SCIM_MEDIA_TYPE } });
82
82
  expectSCIMResponse(discoveryResponse, 200);
83
- expect(await readJson(discoveryResponse)).toMatchObject({
83
+ const discovery = await readJson(discoveryResponse);
84
+ expect(discovery).toMatchObject({
84
85
  patch: { supported: true },
85
86
  filter: { supported: true },
86
87
  meta: {
@@ -214,9 +215,10 @@ async function runSCIMLifecycle(options) {
214
215
  });
215
216
  if (options.projectionFailure) {
216
217
  options.projectionFailure.enable();
217
- expect(await expectSCIMErrorResponse(await addMember().finally(() => {
218
+ const failedAddResponse = await addMember().finally(() => {
218
219
  options.projectionFailure?.disable();
219
- }), 500)).toEqual({
220
+ });
221
+ expect(await expectSCIMErrorResponse(failedAddResponse, 500)).toEqual({
220
222
  schemas: [SCIM_ERROR_SCHEMA],
221
223
  status: "500",
222
224
  detail: "SCIM projection reconciliation failed"
@@ -231,7 +233,8 @@ async function runSCIMLifecycle(options) {
231
233
  expect((await readJson(addMemberResponse)).members).toEqual([expect.objectContaining({ value: createdUser.id })]);
232
234
  const groupWithMemberResponse = await request(`/Groups/${encodeURIComponent(createdGroup.id)}`);
233
235
  expectSCIMResponse(groupWithMemberResponse, 200);
234
- expect((await readJson(groupWithMemberResponse)).members).toEqual([expect.objectContaining({
236
+ const groupWithMember = await readJson(groupWithMemberResponse);
237
+ expect(groupWithMember.members).toEqual([expect.objectContaining({
235
238
  value: createdUser.id,
236
239
  type: "User",
237
240
  $ref: userLocation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/test-utils",
3
- "version": "1.7.12",
3
+ "version": "1.7.13",
4
4
  "description": "Testing utilities for Better Auth adapter development",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,15 +36,15 @@
36
36
  }
37
37
  },
38
38
  "devDependencies": {
39
- "tsdown": "0.21.10",
39
+ "tsdown": "0.23.1",
40
40
  "vitest": "^5.0.0",
41
- "@better-auth/core": "1.7.12",
42
- "better-auth": "1.7.12"
41
+ "@better-auth/core": "1.7.13",
42
+ "better-auth": "1.7.13"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vitest": "^4.0.0 || ^5.0.0",
46
- "@better-auth/core": "^1.7.12",
47
- "better-auth": "^1.7.12"
46
+ "@better-auth/core": "^1.7.13",
47
+ "better-auth": "^1.7.13"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsdown",