@convex-dev/better-auth 0.10.13 → 0.11.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.
- package/dist/auth-options.d.ts.map +1 -1
- package/dist/auth-options.js +0 -2
- package/dist/auth-options.js.map +1 -1
- package/dist/client/adapter-utils.d.ts +10 -10
- package/dist/client/adapter-utils.d.ts.map +1 -1
- package/dist/client/adapter-utils.js +41 -32
- package/dist/client/adapter-utils.js.map +1 -1
- package/dist/client/adapter.d.ts +1 -1
- package/dist/client/adapter.d.ts.map +1 -1
- package/dist/client/adapter.js +113 -7
- package/dist/client/adapter.js.map +1 -1
- package/dist/client/create-api.d.ts +8 -7
- package/dist/client/create-api.d.ts.map +1 -1
- package/dist/client/create-api.js +1 -0
- package/dist/client/create-api.js.map +1 -1
- package/dist/client/create-client.d.ts +1 -1
- package/dist/client/create-client.d.ts.map +1 -1
- package/dist/client/create-client.js +8 -7
- package/dist/client/create-client.js.map +1 -1
- package/dist/client/create-schema.d.ts +0 -1
- package/dist/client/create-schema.d.ts.map +1 -1
- package/dist/client/create-schema.js +0 -1
- package/dist/client/create-schema.js.map +1 -1
- package/dist/component/_generated/api.d.ts +12 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +7407 -92
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/adapter.d.ts +8 -7
- package/dist/component/adapter.d.ts.map +1 -1
- package/dist/component/adapterTest.d.ts +1 -7
- package/dist/component/adapterTest.d.ts.map +1 -1
- package/dist/component/adapterTest.js +193 -390
- package/dist/component/adapterTest.js.map +1 -1
- package/dist/component/schema.d.ts +35 -74
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +16 -21
- package/dist/component/schema.js.map +1 -1
- package/dist/component/testProfiles/adapterAdditionalFields.d.ts +131 -0
- package/dist/component/testProfiles/adapterAdditionalFields.d.ts.map +1 -0
- package/dist/component/testProfiles/adapterAdditionalFields.js +5 -0
- package/dist/component/testProfiles/adapterAdditionalFields.js.map +1 -0
- package/dist/component/testProfiles/adapterOrganizationJoins.d.ts +131 -0
- package/dist/component/testProfiles/adapterOrganizationJoins.d.ts.map +1 -0
- package/dist/component/testProfiles/adapterOrganizationJoins.js +5 -0
- package/dist/component/testProfiles/adapterOrganizationJoins.js.map +1 -0
- package/dist/component/testProfiles/adapterPluginTable.d.ts +131 -0
- package/dist/component/testProfiles/adapterPluginTable.d.ts.map +1 -0
- package/dist/component/testProfiles/adapterPluginTable.js +5 -0
- package/dist/component/testProfiles/adapterPluginTable.js.map +1 -0
- package/dist/component/testProfiles/adapterRenameField.d.ts +131 -0
- package/dist/component/testProfiles/adapterRenameField.d.ts.map +1 -0
- package/dist/component/testProfiles/adapterRenameField.js +5 -0
- package/dist/component/testProfiles/adapterRenameField.js.map +1 -0
- package/dist/component/testProfiles/adapterRenameUserCustom.d.ts +131 -0
- package/dist/component/testProfiles/adapterRenameUserCustom.d.ts.map +1 -0
- package/dist/component/testProfiles/adapterRenameUserCustom.js +5 -0
- package/dist/component/testProfiles/adapterRenameUserCustom.js.map +1 -0
- package/dist/component/testProfiles/adapterRenameUserTable.d.ts +131 -0
- package/dist/component/testProfiles/adapterRenameUserTable.d.ts.map +1 -0
- package/dist/component/testProfiles/adapterRenameUserTable.js +5 -0
- package/dist/component/testProfiles/adapterRenameUserTable.js.map +1 -0
- package/dist/component/testProfiles/auth-options.profile-additional-fields.d.ts +3 -0
- package/dist/component/testProfiles/auth-options.profile-additional-fields.d.ts.map +1 -0
- package/dist/component/testProfiles/auth-options.profile-additional-fields.js +38 -0
- package/dist/component/testProfiles/auth-options.profile-additional-fields.js.map +1 -0
- package/dist/component/testProfiles/auth-options.profile-plugin-table.d.ts +3 -0
- package/dist/component/testProfiles/auth-options.profile-plugin-table.d.ts.map +1 -0
- package/dist/component/testProfiles/auth-options.profile-plugin-table.js +92 -0
- package/dist/component/testProfiles/auth-options.profile-plugin-table.js.map +1 -0
- package/dist/component/testProfiles/auth-options.profile-rename-joins.d.ts +6 -0
- package/dist/component/testProfiles/auth-options.profile-rename-joins.d.ts.map +1 -0
- package/dist/component/testProfiles/auth-options.profile-rename-joins.js +49 -0
- package/dist/component/testProfiles/auth-options.profile-rename-joins.js.map +1 -0
- package/dist/component/testProfiles/schema.profile-additional-fields.d.ts +227 -0
- package/dist/component/testProfiles/schema.profile-additional-fields.d.ts.map +1 -0
- package/dist/component/testProfiles/schema.profile-additional-fields.js +37 -0
- package/dist/component/testProfiles/schema.profile-additional-fields.js.map +1 -0
- package/dist/component/testProfiles/schema.profile-plugin-table.d.ts +450 -0
- package/dist/component/testProfiles/schema.profile-plugin-table.d.ts.map +1 -0
- package/dist/component/testProfiles/schema.profile-plugin-table.js +116 -0
- package/dist/component/testProfiles/schema.profile-plugin-table.js.map +1 -0
- package/dist/nextjs/index.d.ts.map +1 -1
- package/dist/nextjs/index.js +1 -0
- package/dist/nextjs/index.js.map +1 -1
- package/dist/plugins/convex/index.d.ts +131 -12
- package/dist/plugins/convex/index.d.ts.map +1 -1
- package/dist/plugins/convex/index.js +12 -5
- package/dist/plugins/convex/index.js.map +1 -1
- package/dist/plugins/cross-domain/client.d.ts +1 -1
- package/dist/plugins/cross-domain/index.d.ts +126 -1
- package/dist/plugins/cross-domain/index.d.ts.map +1 -1
- package/dist/plugins/cross-domain/index.js +10 -15
- package/dist/plugins/cross-domain/index.js.map +1 -1
- package/dist/react-start/index.d.ts.map +1 -1
- package/dist/react-start/index.js +1 -0
- package/dist/react-start/index.js.map +1 -1
- package/dist/test/adapter-factory/auth-flow.d.ts +42 -0
- package/dist/test/adapter-factory/auth-flow.d.ts.map +1 -0
- package/dist/test/adapter-factory/auth-flow.js +145 -0
- package/dist/test/adapter-factory/auth-flow.js.map +1 -0
- package/dist/test/adapter-factory/basic.d.ts +190 -0
- package/dist/test/adapter-factory/basic.d.ts.map +1 -0
- package/dist/test/adapter-factory/basic.js +2713 -0
- package/dist/test/adapter-factory/basic.js.map +1 -0
- package/dist/test/adapter-factory/convex-custom.d.ts +18 -0
- package/dist/test/adapter-factory/convex-custom.d.ts.map +1 -0
- package/dist/test/adapter-factory/convex-custom.js +610 -0
- package/dist/test/adapter-factory/convex-custom.js.map +1 -0
- package/dist/test/adapter-factory/index.d.ts +11 -0
- package/dist/test/adapter-factory/index.d.ts.map +1 -0
- package/dist/test/adapter-factory/index.js +11 -0
- package/dist/test/adapter-factory/index.js.map +1 -0
- package/dist/test/adapter-factory/joins.d.ts +18 -0
- package/dist/test/adapter-factory/joins.d.ts.map +1 -0
- package/dist/test/adapter-factory/joins.js +22 -0
- package/dist/test/adapter-factory/joins.js.map +1 -0
- package/dist/test/adapter-factory/number-id.d.ts +18 -0
- package/dist/test/adapter-factory/number-id.d.ts.map +1 -0
- package/dist/test/adapter-factory/number-id.js +36 -0
- package/dist/test/adapter-factory/number-id.js.map +1 -0
- package/dist/test/adapter-factory/profile-additional-fields.d.ts +71 -0
- package/dist/test/adapter-factory/profile-additional-fields.d.ts.map +1 -0
- package/dist/test/adapter-factory/profile-additional-fields.js +44 -0
- package/dist/test/adapter-factory/profile-additional-fields.js.map +1 -0
- package/dist/test/adapter-factory/profile-plugin-table.d.ts +19 -0
- package/dist/test/adapter-factory/profile-plugin-table.d.ts.map +1 -0
- package/dist/test/adapter-factory/profile-plugin-table.js +25 -0
- package/dist/test/adapter-factory/profile-plugin-table.js.map +1 -0
- package/dist/test/adapter-factory/profile-rename-joins.d.ts +73 -0
- package/dist/test/adapter-factory/profile-rename-joins.d.ts.map +1 -0
- package/dist/test/adapter-factory/profile-rename-joins.js +34 -0
- package/dist/test/adapter-factory/profile-rename-joins.js.map +1 -0
- package/dist/test/adapter-factory/transactions.d.ts +21 -0
- package/dist/test/adapter-factory/transactions.d.ts.map +1 -0
- package/dist/test/adapter-factory/transactions.js +28 -0
- package/dist/test/adapter-factory/transactions.js.map +1 -0
- package/dist/test/adapter-factory/uuid.d.ts +18 -0
- package/dist/test/adapter-factory/uuid.d.ts.map +1 -0
- package/dist/test/adapter-factory/uuid.js +58 -0
- package/dist/test/adapter-factory/uuid.js.map +1 -0
- package/dist/utils/index.d.ts +18 -3
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +8 -4
- package/src/auth-options.ts +0 -2
- package/src/client/adapter-utils.ts +80 -73
- package/src/client/adapter.test.ts +2 -74
- package/src/client/adapter.ts +142 -7
- package/src/client/create-api.ts +1 -0
- package/src/client/create-client.ts +14 -6
- package/src/client/create-schema.ts +0 -1
- package/src/component/_generated/api.ts +12 -0
- package/src/component/_generated/component.ts +19454 -215
- package/src/component/adapterTest.ts +250 -466
- package/src/component/schema.ts +21 -26
- package/src/component/testProfiles/adapterAdditionalFields.ts +13 -0
- package/src/component/testProfiles/adapterOrganizationJoins.ts +13 -0
- package/src/component/testProfiles/adapterPluginTable.ts +13 -0
- package/src/component/testProfiles/adapterRenameField.ts +13 -0
- package/src/component/testProfiles/adapterRenameUserCustom.ts +13 -0
- package/src/component/testProfiles/adapterRenameUserTable.ts +13 -0
- package/src/component/testProfiles/auth-options.profile-additional-fields.ts +39 -0
- package/src/component/testProfiles/auth-options.profile-plugin-table.ts +93 -0
- package/src/component/testProfiles/auth-options.profile-rename-joins.ts +54 -0
- package/src/component/testProfiles/schema.profile-additional-fields.ts +39 -0
- package/src/component/testProfiles/schema.profile-plugin-table.ts +130 -0
- package/src/nextjs/index.ts +1 -0
- package/src/plugins/convex/index.test.ts +55 -0
- package/src/plugins/convex/index.ts +26 -11
- package/src/plugins/cross-domain/index.test.ts +67 -0
- package/src/plugins/cross-domain/index.ts +10 -21
- package/src/react-start/index.ts +1 -0
- package/src/test/adapter-factory/auth-flow.ts +170 -0
- package/src/test/adapter-factory/basic.ts +3190 -0
- package/src/test/adapter-factory/convex-custom.ts +706 -0
- package/src/test/adapter-factory/index.ts +10 -0
- package/src/test/adapter-factory/joins.ts +28 -0
- package/src/test/adapter-factory/number-id.ts +45 -0
- package/src/test/adapter-factory/profile-additional-fields.ts +84 -0
- package/src/test/adapter-factory/profile-plugin-table.ts +37 -0
- package/src/test/adapter-factory/profile-rename-joins.ts +67 -0
- package/src/test/adapter-factory/transactions.ts +38 -0
- package/src/test/adapter-factory/uuid.ts +67 -0
- package/src/utils/index.ts +25 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const joinsTestSuite: (options?: {
|
|
2
|
+
disableTests?: Partial<Record<"create - should apply default values to fields" | "create - should return null for nullable foreign keys" | "create - should support arrays" | "create - should support json" | "findMany - should be able to perform a complex limited join" | "findMany - should find many models with limit and offset" | "findMany - should find many models with offset" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "findMany - should find many models with sortBy and offset" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should find many with join and offset" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should handle mixed joins correctly when some are missing" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should select fields with one-to-one join" | "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 find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should join a model with modified field name" | "findOne - should not apply defaultValue if value not found" | "findOne - should return an object for one-to-one joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findOne - should select fields with one-to-one join" | "findOne - should work with both one-to-one and one-to-many joins" | "init - tests" | "create - should create a model" | "create - should always return an id" | "findOne - should find a model" | "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 additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an array for one-to-many joins" | "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 multiple joins" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should return an empty array when no models are found" | "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 limit" | "findMany - should find many models with sortBy and limit" | "update - should update a model" | "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" | "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 - 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 return empty array for one-to-many join when joined records don't exist" | "update - should support multiple where conditions under AND connector with unique field", boolean> & {
|
|
3
|
+
ALL?: boolean;
|
|
4
|
+
}> | undefined;
|
|
5
|
+
} | undefined) => (helpers: {
|
|
6
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
7
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
8
|
+
adapterDisplayName: string;
|
|
9
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
10
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
11
|
+
cleanup: () => Promise<void>;
|
|
12
|
+
runMigrations: () => Promise<void>;
|
|
13
|
+
prefixTests?: string | undefined;
|
|
14
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
15
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
16
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
//# sourceMappingURL=joins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joins.d.ts","sourceRoot":"","sources":["../../../src/test/adapter-factory/joins.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;;;;;;;eAwB8/H,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBADzrI,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createTestSuite } from "@better-auth/test-utils/adapter";
|
|
2
|
+
import { expect } from "vitest";
|
|
3
|
+
import { getNormalTestSuiteTests } from "./basic.js";
|
|
4
|
+
export const joinsTestSuite = createTestSuite("joins", {
|
|
5
|
+
defaultBetterAuthOptions: {
|
|
6
|
+
experimental: {
|
|
7
|
+
joins: true,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
alwaysMigrate: true,
|
|
11
|
+
prefixTests: "joins",
|
|
12
|
+
}, (helpers) => {
|
|
13
|
+
const { "create - should use generateId if provided": _, ...normalTests } = getNormalTestSuiteTests({ ...helpers });
|
|
14
|
+
return {
|
|
15
|
+
"init - tests": async () => {
|
|
16
|
+
const opts = helpers.getBetterAuthOptions();
|
|
17
|
+
expect(opts.experimental?.joins).toBe(true);
|
|
18
|
+
},
|
|
19
|
+
...normalTests,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=joins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joins.js","sourceRoot":"","sources":["../../../src/test/adapter-factory/joins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAC5C,OAAO,EACP;IACC,wBAAwB,EAAE;QACzB,YAAY,EAAE;YACb,KAAK,EAAE,IAAI;SACX;KACD;IACD,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE,OAAO;CACpB,EACD,CAAC,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,4CAA4C,EAAE,CAAC,EAAE,GAAG,WAAW,EAAE,GACxE,uBAAuB,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAEzC,OAAO;QACN,cAAc,EAAE,KAAK,IAAI,EAAE;YAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;YAC5C,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;QACD,GAAG,WAAW;KACd,CAAC;AACH,CAAC,CACD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const numberIdTestSuite: (options?: {
|
|
2
|
+
disableTests?: Partial<Record<"create - should apply default values to fields" | "create - should return null for nullable foreign keys" | "create - should support arrays" | "create - should support json" | "findMany - should be able to perform a complex limited join" | "findMany - should find many models with limit and offset" | "findMany - should find many models with offset" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "findMany - should find many models with sortBy and offset" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should find many with join and offset" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should handle mixed joins correctly when some are missing" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should select fields with one-to-one join" | "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 find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should join a model with modified field name" | "findOne - should not apply defaultValue if value not found" | "findOne - should return an object for one-to-one joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findOne - should select fields with one-to-one join" | "findOne - should work with both one-to-one and one-to-many joins" | "init - tests" | "create - should create a model" | "create - should always return an id" | "findOne - should find a model" | "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 additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an array for one-to-many joins" | "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 multiple joins" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should return an empty array when no models are found" | "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 limit" | "findMany - should find many models with sortBy and limit" | "update - should update a model" | "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" | "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 - 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 return empty array for one-to-many join when joined records don't exist" | "update - should support multiple where conditions under AND connector with unique field" | "create - should return a number id", boolean> & {
|
|
3
|
+
ALL?: boolean;
|
|
4
|
+
}> | undefined;
|
|
5
|
+
} | undefined) => (helpers: {
|
|
6
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
7
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
8
|
+
adapterDisplayName: string;
|
|
9
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
10
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
11
|
+
cleanup: () => Promise<void>;
|
|
12
|
+
runMigrations: () => Promise<void>;
|
|
13
|
+
prefixTests?: string | undefined;
|
|
14
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
15
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
16
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
//# sourceMappingURL=number-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-id.d.ts","sourceRoot":"","sources":["../../../src/test/adapter-factory/number-id.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;eAwCi+G,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBAD/pH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createTestSuite } from "@better-auth/test-utils/adapter";
|
|
2
|
+
import { expect } from "vitest";
|
|
3
|
+
import { getNormalTestSuiteTests } from "./basic.js";
|
|
4
|
+
export const numberIdTestSuite = createTestSuite("number-id", {
|
|
5
|
+
defaultBetterAuthOptions: {
|
|
6
|
+
advanced: {
|
|
7
|
+
database: {
|
|
8
|
+
generateId: "serial",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
alwaysMigrate: true,
|
|
13
|
+
prefixTests: "number-id",
|
|
14
|
+
}, (helpers) => {
|
|
15
|
+
const { "create - should use generateId if provided": _, ...normalTests } = getNormalTestSuiteTests({ ...helpers });
|
|
16
|
+
return {
|
|
17
|
+
"init - tests": async () => {
|
|
18
|
+
const opts = helpers.getBetterAuthOptions();
|
|
19
|
+
expect(opts.advanced?.database?.useNumberId ||
|
|
20
|
+
opts.advanced?.database?.generateId === "serial").toBe(true);
|
|
21
|
+
},
|
|
22
|
+
"create - should return a number id": async () => {
|
|
23
|
+
const user = await helpers.generate("user");
|
|
24
|
+
const res = await helpers.adapter.create({
|
|
25
|
+
model: "user",
|
|
26
|
+
data: user,
|
|
27
|
+
forceAllowId: true,
|
|
28
|
+
});
|
|
29
|
+
expect(res).toHaveProperty("id");
|
|
30
|
+
expect(typeof res.id).toBe("string");
|
|
31
|
+
expect(Number(res.id)).toBeGreaterThan(0);
|
|
32
|
+
},
|
|
33
|
+
...normalTests,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=number-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-id.js","sourceRoot":"","sources":["../../../src/test/adapter-factory/number-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAC/C,WAAW,EACX;IACC,wBAAwB,EAAE;QACzB,QAAQ,EAAE;YACT,QAAQ,EAAE;gBACT,UAAU,EAAE,QAAQ;aACpB;SACD;KACD;IACD,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE,WAAW;CACxB,EACD,CAAC,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,4CAA4C,EAAE,CAAC,EAAE,GAAG,WAAW,EAAE,GACxE,uBAAuB,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAEzC,OAAO;QACN,cAAc,EAAE,KAAK,IAAI,EAAE;YAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;YAC5C,MAAM,CACJ,IAAI,CAAC,QAAQ,EAAE,QAAgB,EAAE,WAAW;gBAC5C,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,KAAK,QAAQ,CACjD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,CAAC;QACD,oCAAoC,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAO;gBAC9C,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,IAAI;gBACV,YAAY,EAAE,IAAI;aAClB,CAAC,CAAC;YACH,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,GAAG,WAAW;KACd,CAAC;AACH,CAAC,CACD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export declare const ADDITIONAL_FIELDS_NORMAL_TESTS: readonly ["deleteMany - should delete many models with numeric values", "findMany - should find many models with sortBy", "findMany - should find many models with sortBy and limit", "findMany - should find many with join and sortBy", "findOne - should find a model with additional fields"];
|
|
2
|
+
export declare const ADDITIONAL_FIELDS_AUTH_FLOW_TEST: "should sign up with additional fields";
|
|
3
|
+
export declare const coreNormalTestSuite: (options?: {
|
|
4
|
+
disableTests?: Partial<Record<"init - tests", boolean> & {
|
|
5
|
+
ALL?: boolean;
|
|
6
|
+
}> | undefined;
|
|
7
|
+
} | undefined) => (helpers: {
|
|
8
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
9
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
10
|
+
adapterDisplayName: string;
|
|
11
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
12
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
13
|
+
cleanup: () => Promise<void>;
|
|
14
|
+
runMigrations: () => Promise<void>;
|
|
15
|
+
prefixTests?: string | undefined;
|
|
16
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
17
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
18
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
export declare const additionalFieldsNormalTestSuite: (options?: {
|
|
21
|
+
disableTests?: Partial<Record<string | number, boolean> & {
|
|
22
|
+
ALL?: boolean;
|
|
23
|
+
}> | undefined;
|
|
24
|
+
} | undefined) => (helpers: {
|
|
25
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
26
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
27
|
+
adapterDisplayName: string;
|
|
28
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
29
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
30
|
+
cleanup: () => Promise<void>;
|
|
31
|
+
runMigrations: () => Promise<void>;
|
|
32
|
+
prefixTests?: string | undefined;
|
|
33
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
34
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
35
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
36
|
+
}) => Promise<void>;
|
|
37
|
+
export declare const coreAuthFlowTestSuite: (options?: {
|
|
38
|
+
disableTests?: Partial<Record<"should successfully sign up" | "should successfully sign in" | "should successfully get session" | "should not sign in with invalid email" | "should store and retrieve timestamps correctly across timezones", boolean> & {
|
|
39
|
+
ALL?: boolean;
|
|
40
|
+
}> | undefined;
|
|
41
|
+
} | undefined) => (helpers: {
|
|
42
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
43
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
44
|
+
adapterDisplayName: string;
|
|
45
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
46
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
47
|
+
cleanup: () => Promise<void>;
|
|
48
|
+
runMigrations: () => Promise<void>;
|
|
49
|
+
prefixTests?: string | undefined;
|
|
50
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
51
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
52
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
53
|
+
}) => Promise<void>;
|
|
54
|
+
export declare const additionalFieldsAuthFlowTestSuite: (options?: {
|
|
55
|
+
disableTests?: Partial<Record<"should sign up with additional fields", boolean> & {
|
|
56
|
+
ALL?: boolean;
|
|
57
|
+
}> | undefined;
|
|
58
|
+
} | undefined) => (helpers: {
|
|
59
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
60
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
61
|
+
adapterDisplayName: string;
|
|
62
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
63
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
64
|
+
cleanup: () => Promise<void>;
|
|
65
|
+
runMigrations: () => Promise<void>;
|
|
66
|
+
prefixTests?: string | undefined;
|
|
67
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
68
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
69
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
70
|
+
}) => Promise<void>;
|
|
71
|
+
//# sourceMappingURL=profile-additional-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-additional-fields.d.ts","sourceRoot":"","sources":["../../../src/test/adapter-factory/profile-additional-fields.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,8BAA8B,mSAMjC,CAAC;AAEX,eAAO,MAAM,gCAAgC,EAC5C,uCAAgD,CAAC;AAkBlD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;eAiD4wE,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBApC58E,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;eAkCgwE,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBA3B58E,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;eAyB0wE,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBAf58E,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;eAa8vE,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBAD58E,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createTestSuite } from "@better-auth/test-utils/adapter";
|
|
2
|
+
import { expect } from "vitest";
|
|
3
|
+
import { getNormalTestSuiteTests } from "./basic.js";
|
|
4
|
+
import { AUTH_FLOW_DEFAULT_BETTER_AUTH_OPTIONS, getAuthFlowSuiteTests, } from "./auth-flow.js";
|
|
5
|
+
export const ADDITIONAL_FIELDS_NORMAL_TESTS = [
|
|
6
|
+
"deleteMany - should delete many models with numeric values",
|
|
7
|
+
"findMany - should find many models with sortBy",
|
|
8
|
+
"findMany - should find many models with sortBy and limit",
|
|
9
|
+
"findMany - should find many with join and sortBy",
|
|
10
|
+
"findOne - should find a model with additional fields",
|
|
11
|
+
];
|
|
12
|
+
export const ADDITIONAL_FIELDS_AUTH_FLOW_TEST = "should sign up with additional fields";
|
|
13
|
+
const pickTests = (tests, testNames) => Object.fromEntries(Object.entries(tests).filter(([testName]) => testNames.includes(testName)));
|
|
14
|
+
const omitTests = (tests, testNames) => Object.fromEntries(Object.entries(tests).filter(([testName]) => !testNames.includes(testName)));
|
|
15
|
+
export const coreNormalTestSuite = createTestSuite("normal", {}, (helpers, debugTools) => {
|
|
16
|
+
const tests = getNormalTestSuiteTests(helpers, debugTools);
|
|
17
|
+
return {
|
|
18
|
+
"init - tests": async () => {
|
|
19
|
+
const opts = helpers.getBetterAuthOptions();
|
|
20
|
+
expect(opts.advanced?.database?.generateId !== "serial").toBeTruthy();
|
|
21
|
+
},
|
|
22
|
+
...omitTests(tests, ADDITIONAL_FIELDS_NORMAL_TESTS),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
export const additionalFieldsNormalTestSuite = createTestSuite("normal-additional-fields", {}, (helpers, debugTools) => {
|
|
26
|
+
const tests = getNormalTestSuiteTests(helpers, debugTools);
|
|
27
|
+
return pickTests(tests, ADDITIONAL_FIELDS_NORMAL_TESTS);
|
|
28
|
+
});
|
|
29
|
+
export const coreAuthFlowTestSuite = createTestSuite("auth-flow", {
|
|
30
|
+
defaultBetterAuthOptions: AUTH_FLOW_DEFAULT_BETTER_AUTH_OPTIONS,
|
|
31
|
+
}, (helpers) => {
|
|
32
|
+
const tests = getAuthFlowSuiteTests(helpers);
|
|
33
|
+
const { [ADDITIONAL_FIELDS_AUTH_FLOW_TEST]: _skip, ...remaining } = tests;
|
|
34
|
+
return remaining;
|
|
35
|
+
});
|
|
36
|
+
export const additionalFieldsAuthFlowTestSuite = createTestSuite("auth-flow-additional-fields", {
|
|
37
|
+
defaultBetterAuthOptions: AUTH_FLOW_DEFAULT_BETTER_AUTH_OPTIONS,
|
|
38
|
+
}, (helpers) => {
|
|
39
|
+
const tests = getAuthFlowSuiteTests(helpers);
|
|
40
|
+
return {
|
|
41
|
+
[ADDITIONAL_FIELDS_AUTH_FLOW_TEST]: tests[ADDITIONAL_FIELDS_AUTH_FLOW_TEST],
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=profile-additional-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-additional-fields.js","sourceRoot":"","sources":["../../../src/test/adapter-factory/profile-additional-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CA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,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG,eAAe,CAC7D,0BAA0B,EAC1B,EAAE,EACF,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE;IACvB,MAAM,KAAK,GAAG,uBAAuB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC3D,OAAO,SAAS,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;AACzD,CAAC,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CACnD,WAAW,EACX;IACC,wBAAwB,EAAE,qCAAqC;CAC/D,EACD,CAAC,OAAO,EAAE,EAAE;IACX,MAAM,KAAK,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,EAAE,CAAC,gCAAgC,CAAC,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAC1E,OAAO,SAAS,CAAC;AAClB,CAAC,CACD,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,eAAe,CAC/D,6BAA6B,EAC7B;IACC,wBAAwB,EAAE,qCAAqC;CAC/D,EACD,CAAC,OAAO,EAAE,EAAE;IACX,MAAM,KAAK,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO;QACN,CAAC,gCAAgC,CAAC,EACjC,KAAK,CAAC,gCAAgC,CAAC;KACxC,CAAC;AACH,CAAC,CACD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const PLUGIN_TABLE_NORMAL_TESTS: readonly ["create - should apply default values to fields", "create - should return null for nullable foreign keys", "create - should support arrays", "create - should support json", "findMany - should find many with both one-to-one and one-to-many joins", "findMany - should find many with one-to-one join", "findMany - should handle mixed joins correctly when some are missing", "findMany - should return empty array when base records don't exist with joins", "findMany - should return null for one-to-one join when joined records don't exist", "findMany - should select fields with one-to-one join", "findOne - should not apply defaultValue if value not found", "findOne - should return an object for one-to-one joins", "findOne - should return null for one-to-one join when joined record doesn't exist", "findOne - should select fields with one-to-one join", "findOne - should work with both one-to-one and one-to-many joins"];
|
|
2
|
+
export declare const pluginTableNormalTestSuite: (options?: {
|
|
3
|
+
disableTests?: Partial<Record<string | number, boolean> & {
|
|
4
|
+
ALL?: boolean;
|
|
5
|
+
}> | undefined;
|
|
6
|
+
} | undefined) => (helpers: {
|
|
7
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
8
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
9
|
+
adapterDisplayName: string;
|
|
10
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
11
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
12
|
+
cleanup: () => Promise<void>;
|
|
13
|
+
runMigrations: () => Promise<void>;
|
|
14
|
+
prefixTests?: string | undefined;
|
|
15
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
16
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
17
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
//# sourceMappingURL=profile-plugin-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-plugin-table.d.ts","sourceRoot":"","sources":["../../../src/test/adapter-factory/profile-plugin-table.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,o6BAgB5B,CAAC;AAUX,eAAO,MAAM,0BAA0B;;;;;;;;;;;;eAQ6kG,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBADpxG,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createTestSuite } from "@better-auth/test-utils/adapter";
|
|
2
|
+
import { getNormalTestSuiteTests } from "./basic.js";
|
|
3
|
+
export const PLUGIN_TABLE_NORMAL_TESTS = [
|
|
4
|
+
"create - should apply default values to fields",
|
|
5
|
+
"create - should return null for nullable foreign keys",
|
|
6
|
+
"create - should support arrays",
|
|
7
|
+
"create - should support json",
|
|
8
|
+
"findMany - should find many with both one-to-one and one-to-many joins",
|
|
9
|
+
"findMany - should find many with one-to-one join",
|
|
10
|
+
"findMany - should handle mixed joins correctly when some are missing",
|
|
11
|
+
"findMany - should return empty array when base records don't exist with joins",
|
|
12
|
+
"findMany - should return null for one-to-one join when joined records don't exist",
|
|
13
|
+
"findMany - should select fields with one-to-one join",
|
|
14
|
+
"findOne - should not apply defaultValue if value not found",
|
|
15
|
+
"findOne - should return an object for one-to-one joins",
|
|
16
|
+
"findOne - should return null for one-to-one join when joined record doesn't exist",
|
|
17
|
+
"findOne - should select fields with one-to-one join",
|
|
18
|
+
"findOne - should work with both one-to-one and one-to-many joins",
|
|
19
|
+
];
|
|
20
|
+
const pickTests = (tests, testNames) => Object.fromEntries(Object.entries(tests).filter(([testName]) => testNames.includes(testName)));
|
|
21
|
+
export const pluginTableNormalTestSuite = createTestSuite("normal-plugin-table", {}, (helpers, debugTools) => {
|
|
22
|
+
const tests = getNormalTestSuiteTests(helpers, debugTools);
|
|
23
|
+
return pickTests(tests, PLUGIN_TABLE_NORMAL_TESTS);
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=profile-plugin-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-plugin-table.js","sourceRoot":"","sources":["../../../src/test/adapter-factory/profile-plugin-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,gDAAgD;IAChD,uDAAuD;IACvD,gCAAgC;IAChC,8BAA8B;IAC9B,wEAAwE;IACxE,kDAAkD;IAClD,sEAAsE;IACtE,+EAA+E;IAC/E,mFAAmF;IACnF,sDAAsD;IACtD,4DAA4D;IAC5D,wDAAwD;IACxD,mFAAmF;IACnF,qDAAqD;IACrD,kEAAkE;CAC1D,CAAC;AAEX,MAAM,SAAS,GAAG,CAChB,KAAiD,EACjD,SAA4B,EAC5B,EAAE,CACF,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAC3E,CAAC;AAEJ,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CACvD,qBAAqB,EACrB,EAAE,EACF,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE;IACtB,MAAM,KAAK,GAAG,uBAAuB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC3D,OAAO,SAAS,CAAC,KAAK,EAAE,yBAAyB,CAAC,CAAC;AACrD,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export declare const RENAME_FIELD_AND_JOIN_TESTS: readonly ["findOne - should find a model with modified field name", "findOne - should join a model with modified field name", "findOne - should return null for failed base model lookup that has joins"];
|
|
2
|
+
export declare const RENAME_MODEL_USER_CUSTOM_TEST: "findOne - should find a model with modified model name";
|
|
3
|
+
export declare const RENAME_MODEL_USER_TABLE_TEST: "findOne - backwards join with modified field name (session base, users-table join)";
|
|
4
|
+
export declare const MULTI_JOINS_MISSING_ROWS_TEST: "findOne - multiple joins should return result even when some joined tables have no matching rows";
|
|
5
|
+
export declare const renameFieldAndJoinTestSuite: (options?: {
|
|
6
|
+
disableTests?: Partial<Record<string | number, boolean> & {
|
|
7
|
+
ALL?: boolean;
|
|
8
|
+
}> | undefined;
|
|
9
|
+
} | undefined) => (helpers: {
|
|
10
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
11
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
12
|
+
adapterDisplayName: string;
|
|
13
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
14
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
15
|
+
cleanup: () => Promise<void>;
|
|
16
|
+
runMigrations: () => Promise<void>;
|
|
17
|
+
prefixTests?: string | undefined;
|
|
18
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
19
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
20
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
21
|
+
}) => Promise<void>;
|
|
22
|
+
export declare const renameModelUserCustomTestSuite: (options?: {
|
|
23
|
+
disableTests?: Partial<Record<"findOne - should find a model with modified model name", boolean> & {
|
|
24
|
+
ALL?: boolean;
|
|
25
|
+
}> | undefined;
|
|
26
|
+
} | undefined) => (helpers: {
|
|
27
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
28
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
29
|
+
adapterDisplayName: string;
|
|
30
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
31
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
32
|
+
cleanup: () => Promise<void>;
|
|
33
|
+
runMigrations: () => Promise<void>;
|
|
34
|
+
prefixTests?: string | undefined;
|
|
35
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
36
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
37
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
export declare const renameModelUserTableTestSuite: (options?: {
|
|
40
|
+
disableTests?: Partial<Record<"findOne - backwards join with modified field name (session base, users-table join)", boolean> & {
|
|
41
|
+
ALL?: boolean;
|
|
42
|
+
}> | undefined;
|
|
43
|
+
} | undefined) => (helpers: {
|
|
44
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
45
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
46
|
+
adapterDisplayName: string;
|
|
47
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
48
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
49
|
+
cleanup: () => Promise<void>;
|
|
50
|
+
runMigrations: () => Promise<void>;
|
|
51
|
+
prefixTests?: string | undefined;
|
|
52
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
53
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
54
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
55
|
+
}) => Promise<void>;
|
|
56
|
+
export declare const multiJoinsMissingRowsTestSuite: (options?: {
|
|
57
|
+
disableTests?: Partial<Record<"findOne - multiple joins should return result even when some joined tables have no matching rows", boolean> & {
|
|
58
|
+
ALL?: boolean;
|
|
59
|
+
}> | undefined;
|
|
60
|
+
} | undefined) => (helpers: {
|
|
61
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
62
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
63
|
+
adapterDisplayName: string;
|
|
64
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
65
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
66
|
+
cleanup: () => Promise<void>;
|
|
67
|
+
runMigrations: () => Promise<void>;
|
|
68
|
+
prefixTests?: string | undefined;
|
|
69
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
70
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
71
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
72
|
+
}) => Promise<void>;
|
|
73
|
+
//# sourceMappingURL=profile-rename-joins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-rename-joins.d.ts","sourceRoot":"","sources":["../../../src/test/adapter-factory/profile-rename-joins.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,2BAA2B,2MAI9B,CAAC;AAEX,eAAO,MAAM,6BAA6B,EACxC,wDAAiE,CAAC;AAEpE,eAAO,MAAM,4BAA4B,EACvC,oFAA6F,CAAC;AAEhG,eAAO,MAAM,6BAA6B,EACxC,kGAA2G,CAAC;AAE9G,eAAO,MAAM,2BAA2B;;;;;;;;;;;;eAyCkgF,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBAlC1sF,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;eAgC+/E,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBAvB1sF,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;eAqBggF,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBAZ1sF,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;eAU+/E,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBAD1sF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createTestSuite } from "@better-auth/test-utils/adapter";
|
|
2
|
+
import { getNormalTestSuiteTests } from "./basic.js";
|
|
3
|
+
const pickTests = (tests, testNames) => Object.fromEntries(Object.entries(tests).filter(([testName]) => testNames.includes(testName)));
|
|
4
|
+
export const RENAME_FIELD_AND_JOIN_TESTS = [
|
|
5
|
+
"findOne - should find a model with modified field name",
|
|
6
|
+
"findOne - should join a model with modified field name",
|
|
7
|
+
"findOne - should return null for failed base model lookup that has joins",
|
|
8
|
+
];
|
|
9
|
+
export const RENAME_MODEL_USER_CUSTOM_TEST = "findOne - should find a model with modified model name";
|
|
10
|
+
export const RENAME_MODEL_USER_TABLE_TEST = "findOne - backwards join with modified field name (session base, users-table join)";
|
|
11
|
+
export const MULTI_JOINS_MISSING_ROWS_TEST = "findOne - multiple joins should return result even when some joined tables have no matching rows";
|
|
12
|
+
export const renameFieldAndJoinTestSuite = createTestSuite("normal-rename-field-and-join", {}, (helpers, debugTools) => {
|
|
13
|
+
const tests = getNormalTestSuiteTests(helpers, debugTools);
|
|
14
|
+
return pickTests(tests, RENAME_FIELD_AND_JOIN_TESTS);
|
|
15
|
+
});
|
|
16
|
+
export const renameModelUserCustomTestSuite = createTestSuite("normal-rename-model-user-custom", {}, (helpers, debugTools) => {
|
|
17
|
+
const tests = getNormalTestSuiteTests(helpers, debugTools);
|
|
18
|
+
return {
|
|
19
|
+
[RENAME_MODEL_USER_CUSTOM_TEST]: tests[RENAME_MODEL_USER_CUSTOM_TEST],
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
export const renameModelUserTableTestSuite = createTestSuite("normal-rename-model-user-table", {}, (helpers, debugTools) => {
|
|
23
|
+
const tests = getNormalTestSuiteTests(helpers, debugTools);
|
|
24
|
+
return {
|
|
25
|
+
[RENAME_MODEL_USER_TABLE_TEST]: tests[RENAME_MODEL_USER_TABLE_TEST],
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
export const multiJoinsMissingRowsTestSuite = createTestSuite("normal-multi-joins-missing-rows", {}, (helpers, debugTools) => {
|
|
29
|
+
const tests = getNormalTestSuiteTests(helpers, debugTools);
|
|
30
|
+
return {
|
|
31
|
+
[MULTI_JOINS_MISSING_ROWS_TEST]: tests[MULTI_JOINS_MISSING_ROWS_TEST],
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=profile-rename-joins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-rename-joins.js","sourceRoot":"","sources":["../../../src/test/adapter-factory/profile-rename-joins.ts"],"names":[],"mappings":"AAAA,O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OAAO,EAAE,UAAU,EAAE,EAAE;IACtB,MAAM,KAAK,GAAG,uBAAuB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC3D,OAAO;QACL,CAAC,4BAA4B,CAAC,EAAE,KAAK,CAAC,4BAA4B,CAAC;KACpE,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG,eAAe,CAC3D,iCAAiC,EACjC,EAAE,EACF,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE;IACtB,MAAM,KAAK,GAAG,uBAAuB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC3D,OAAO;QACL,CAAC,6BAA6B,CAAC,EAAE,KAAK,CAAC,6BAA6B,CAAC;KACtE,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This test suite tests the transaction functionality of the adapter.
|
|
3
|
+
*/
|
|
4
|
+
export declare const transactionsTestSuite: (options?: {
|
|
5
|
+
disableTests?: Partial<Record<"transaction - should rollback failing transaction", boolean> & {
|
|
6
|
+
ALL?: boolean;
|
|
7
|
+
}> | undefined;
|
|
8
|
+
} | undefined) => (helpers: {
|
|
9
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
10
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
11
|
+
adapterDisplayName: string;
|
|
12
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
13
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
14
|
+
cleanup: () => Promise<void>;
|
|
15
|
+
runMigrations: () => Promise<void>;
|
|
16
|
+
prefixTests?: string | undefined;
|
|
17
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
18
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
19
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
20
|
+
}) => Promise<void>;
|
|
21
|
+
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../src/test/adapter-factory/transactions.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;eA+Bs6G,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBADxmH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createTestSuite } from "@better-auth/test-utils/adapter";
|
|
2
|
+
import { expect } from "vitest";
|
|
3
|
+
/**
|
|
4
|
+
* This test suite tests the transaction functionality of the adapter.
|
|
5
|
+
*/
|
|
6
|
+
export const transactionsTestSuite = createTestSuite("transactions", {}, ({ adapter, generate, hardCleanup }) => ({
|
|
7
|
+
"transaction - should rollback failing transaction": async ({ skip }) => {
|
|
8
|
+
const isEnabled = adapter.options?.adapterConfig.transaction;
|
|
9
|
+
if (!isEnabled) {
|
|
10
|
+
skip(`Skipping test: ${adapter.options?.adapterConfig.adapterName} does not support transactions`);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const user1 = await generate("user");
|
|
14
|
+
await expect(adapter.transaction(async (tx) => {
|
|
15
|
+
await tx.create({ model: "user", data: user1, forceAllowId: true });
|
|
16
|
+
const users = await tx.findMany({ model: "user" });
|
|
17
|
+
expect(users).toHaveLength(1);
|
|
18
|
+
throw new Error("Simulated failure");
|
|
19
|
+
})).rejects.toThrow("Simulated failure");
|
|
20
|
+
const result = await adapter.findMany({
|
|
21
|
+
model: "user",
|
|
22
|
+
});
|
|
23
|
+
//Transactions made rows are unable to be automatically cleaned up, so we need to clean them up manually
|
|
24
|
+
await hardCleanup();
|
|
25
|
+
expect(result.length).toBe(0);
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,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C,QAAQ,CAAO;YAC3C,KAAK,EAAE,MAAM;SACb,CAAC,CAAC;QACH,wGAAwG;QACxG,MAAM,WAAW,EAAE,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;CACD,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const uuidTestSuite: (options?: {
|
|
2
|
+
disableTests?: Partial<Record<"create - should apply default values to fields" | "create - should return null for nullable foreign keys" | "create - should support arrays" | "create - should support json" | "findMany - should be able to perform a complex limited join" | "findMany - should find many models with limit and offset" | "findMany - should find many models with offset" | "findMany - should find many models with sortBy and limit and offset" | "findMany - should find many models with sortBy and limit and offset and where" | "findMany - should find many models with sortBy and offset" | "findMany - should find many with both one-to-one and one-to-many joins" | "findMany - should find many with join and offset" | "findMany - should find many with join, where, limit, and offset" | "findMany - should find many with one-to-one join" | "findMany - should handle mixed joins correctly when some are missing" | "findMany - should return empty array when base records don't exist with joins" | "findMany - should return null for one-to-one join when joined records don't exist" | "findMany - should select fields with one-to-one join" | "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 find a model with modified field name" | "findOne - should find a model with modified model name" | "findOne - should join a model with modified field name" | "findOne - should not apply defaultValue if value not found" | "findOne - should return an object for one-to-one joins" | "findOne - should return null for failed base model lookup that has joins" | "findOne - should return null for one-to-one join when joined record doesn't exist" | "findOne - should select fields with one-to-one join" | "findOne - should work with both one-to-one and one-to-many joins" | "init - tests" | "create - should create a model" | "create - should always return an id" | "findOne - should find a model" | "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 additional fields" | "findOne - should select fields" | "findOne - should select fields with one-to-many join" | "findOne - should select fields with multiple joins" | "findOne - should find model with date field" | "findOne - should perform backwards joins" | "findOne - should return an array for one-to-many joins" | "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 multiple joins" | "findMany - should find many with join and sortBy" | "findMany - should find many with join and where clause" | "findMany - should return an empty array when no models are found" | "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 limit" | "findMany - should find many models with sortBy and limit" | "update - should update a model" | "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" | "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 - 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 return empty array for one-to-many join when joined records don't exist" | "update - should support multiple where conditions under AND connector with unique field" | "create - should return a uuid" | "findOne - should find a model using a uuid", boolean> & {
|
|
3
|
+
ALL?: boolean;
|
|
4
|
+
}> | undefined;
|
|
5
|
+
} | undefined) => (helpers: {
|
|
6
|
+
adapter: () => Promise<import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>>;
|
|
7
|
+
log: import("@better-auth/test-utils/adapter").Logger;
|
|
8
|
+
adapterDisplayName: string;
|
|
9
|
+
getBetterAuthOptions: () => import("better-auth").BetterAuthOptions;
|
|
10
|
+
modifyBetterAuthOptions: (options: import("better-auth").BetterAuthOptions) => Promise<import("better-auth").BetterAuthOptions>;
|
|
11
|
+
cleanup: () => Promise<void>;
|
|
12
|
+
runMigrations: () => Promise<void>;
|
|
13
|
+
prefixTests?: string | undefined;
|
|
14
|
+
onTestFinish: (stats: import("@better-auth/test-utils/adapter").TestSuiteStats) => Promise<void>;
|
|
15
|
+
customIdGenerator?: () => any | Promise<any> | undefined;
|
|
16
|
+
transformIdOutput?: (id: any) => string | undefined;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
//# sourceMappingURL=uuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/test/adapter-factory/uuid.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;;;;;;;;;;;eA8D6nF,CAAC;;qBAAmG,CAAC;qBAA2D,CAAC;mBADvzF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createTestSuite } from "@better-auth/test-utils/adapter";
|
|
2
|
+
import { expect } from "vitest";
|
|
3
|
+
import { getNormalTestSuiteTests } from "./basic.js";
|
|
4
|
+
export const uuidTestSuite = createTestSuite("uuid", {
|
|
5
|
+
defaultBetterAuthOptions: {
|
|
6
|
+
advanced: {
|
|
7
|
+
database: {
|
|
8
|
+
generateId: "uuid",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
prefixTests: "uuid",
|
|
13
|
+
alwaysMigrate: true,
|
|
14
|
+
// This is here to overwrite `generateId` functions to generate UUIDs instead of the default.
|
|
15
|
+
// Since existing tests often use generated IDs as well as `forceAllowId` to be true, this is needed to ensure the tests pass.
|
|
16
|
+
customIdGenerator() {
|
|
17
|
+
return crypto.randomUUID();
|
|
18
|
+
},
|
|
19
|
+
}, (helpers) => {
|
|
20
|
+
const { "create - should use generateId if provided": _, ...normalTests } = getNormalTestSuiteTests(helpers);
|
|
21
|
+
return {
|
|
22
|
+
"init - tests": async () => {
|
|
23
|
+
const opts = helpers.getBetterAuthOptions();
|
|
24
|
+
expect(opts.advanced?.database?.generateId === "uuid").toBe(true);
|
|
25
|
+
},
|
|
26
|
+
"create - should return a uuid": async () => {
|
|
27
|
+
const user = await helpers.generate("user");
|
|
28
|
+
const res = await helpers.adapter.create({
|
|
29
|
+
model: "user",
|
|
30
|
+
data: {
|
|
31
|
+
...user,
|
|
32
|
+
//@ts-expect-error - remove id from `user`
|
|
33
|
+
id: undefined,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
expect(res).toHaveProperty("id");
|
|
37
|
+
expect(typeof res.id).toBe("string");
|
|
38
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
39
|
+
expect(res.id).toMatch(uuidRegex);
|
|
40
|
+
},
|
|
41
|
+
"findOne - should find a model using a uuid": async () => {
|
|
42
|
+
const { id: _, ...user } = await helpers.generate("user");
|
|
43
|
+
const res = await helpers.adapter.create({
|
|
44
|
+
model: "user",
|
|
45
|
+
data: user,
|
|
46
|
+
});
|
|
47
|
+
const result = await helpers.adapter.findOne({
|
|
48
|
+
model: "user",
|
|
49
|
+
where: [{ field: "id", value: res.id }],
|
|
50
|
+
});
|
|
51
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
52
|
+
expect(result?.id).toMatch(uuidRegex);
|
|
53
|
+
expect(result).toEqual(res);
|
|
54
|
+
},
|
|
55
|
+
...normalTests,
|
|
56
|
+
};
|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