Skip to content

Commit a3dcb04

Browse files
eluce2claude
andcommitted
Merge main, resolve conflicts
- Use DBAdapterDebugLogOption/DBFieldAttribute from better-auth - Use filemakerConfig property instead of helper function - Keep normalizeBetterAuthFieldType for array type handling Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2 parents c79a5de + 83d9628 commit a3dcb04

File tree

4 files changed

+22
-51
lines changed

4 files changed

+22
-51
lines changed

.beads/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ beads.left.meta.json
3232
beads.right.jsonl
3333
beads.right.meta.json
3434

35+
# Sync state (local-only, per-machine)
36+
# These files are machine-specific and should not be shared across clones
37+
.sync.lock
38+
sync_base.jsonl
39+
3540
# NOTE: Do NOT add negation patterns (e.g., !issues.jsonl) here.
3641
# They would override fork protection in .git/info/exclude, allowing
3742
# contributors to accidentally commit upstream issue databases.

packages/better-auth/src/adapter.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** biome-ignore-all lint/suspicious/noExplicitAny: library code */
22
import { logger } from "better-auth";
3-
import { type CleanedWhere, createAdapter } from "better-auth/adapters";
3+
import { type CleanedWhere, createAdapter, type DBAdapterDebugLogOption } from "better-auth/adapters";
44
import buildQuery from "odata-query";
55
import { prettifyError, z } from "zod/v4";
66
import { createRawFetch, type FmOdataConfig } from "./odata";
@@ -15,11 +15,11 @@ const configSchema = z.object({
1515
}),
1616
});
1717

18-
interface FileMakerAdapterConfig {
18+
export interface FileMakerAdapterConfig {
1919
/**
2020
* Helps you debug issues with the adapter.
2121
*/
22-
debugLogs?: boolean | { isRunningAdapterTests?: boolean };
22+
debugLogs?: DBAdapterDebugLogOption;
2323
/**
2424
* If the table names in the schema are plural.
2525
*/
@@ -168,7 +168,7 @@ export const FileMakerAdapter = (_config: FileMakerAdapterConfig = defaultConfig
168168
logging: config.debugLogs ? "verbose" : "none",
169169
});
170170

171-
return createAdapter({
171+
const adapterFactory = createAdapter({
172172
config: {
173173
adapterId: "filemaker",
174174
adapterName: "FileMaker",
@@ -382,4 +382,8 @@ export const FileMakerAdapter = (_config: FileMakerAdapterConfig = defaultConfig
382382
};
383383
},
384384
});
385+
386+
// Expose the FileMaker config for CLI access
387+
(adapterFactory as any).filemakerConfig = config as FileMakerAdapterConfig;
388+
return adapterFactory;
385389
};

packages/better-auth/src/cli/index.ts

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,16 @@
11
#!/usr/bin/env node --no-warnings
22
import { Command } from "@commander-js/extra-typings";
33
import { logger } from "better-auth";
4-
import { getAdapter, getAuthTables } from "better-auth/db";
4+
import { getAdapter, getSchema } from "better-auth/db";
55
import chalk from "chalk";
66
import fs from "fs-extra";
77
import prompts from "prompts";
8-
import type { AdapterOptions } from "../adapter";
8+
import type { FileMakerAdapterConfig } from "../adapter";
99
import { getConfig } from "../better-auth-cli/utils/get-config";
1010
import { executeMigration, planMigration, prettyPrintMigrationPlan } from "../migrate";
1111
import { createRawFetch } from "../odata";
1212
import "dotenv/config";
1313

14-
function getFileMakerAdapterConfigFromAdapterOptions(
15-
options: unknown,
16-
): AdapterOptions["config"] {
17-
if (!options || typeof options !== "object") {
18-
throw new Error("FileMaker adapter options were missing.");
19-
}
20-
21-
const opts = options as Record<string, unknown>;
22-
23-
// Our adapter returns: { options: { config: FileMakerAdapterConfig } }
24-
if (opts.config && typeof opts.config === "object") {
25-
return opts.config as AdapterOptions["config"];
26-
}
27-
28-
// Some Better Auth versions wrap adapter options under `adapterConfig`.
29-
if (opts.adapterConfig && typeof opts.adapterConfig === "object") {
30-
const adapterConfig = opts.adapterConfig as Record<string, unknown>;
31-
if (adapterConfig.config && typeof adapterConfig.config === "object") {
32-
return adapterConfig.config as AdapterOptions["config"];
33-
}
34-
}
35-
36-
throw new Error(
37-
"Could not locate FileMaker adapter configuration from Better Auth adapter options.",
38-
);
39-
}
40-
4114
async function main() {
4215
const program = new Command();
4316

@@ -77,11 +50,9 @@ async function main() {
7750
return;
7851
}
7952

80-
const betterAuthSchema = getAuthTables(config);
53+
const betterAuthSchema = getSchema(config);
8154

82-
const adapterConfig = getFileMakerAdapterConfigFromAdapterOptions(
83-
adapter.options,
84-
);
55+
const adapterConfig = (adapter as unknown as { filemakerConfig: FileMakerAdapterConfig }).filemakerConfig;
8556
const { fetch } = createRawFetch({
8657
...adapterConfig.odata,
8758
auth:

packages/better-auth/src/migrate.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1+
import type { DBFieldAttribute } from "better-auth/db";
12
import chalk from "chalk";
23
import type { Metadata } from "fm-odata-client";
34
import z from "zod/v4";
45
import type { createRawFetch } from "./odata";
56

6-
type BetterAuthTableField = {
7-
fieldName?: string;
8-
type: unknown;
9-
};
10-
11-
type BetterAuthTableDef = {
12-
modelName: string;
13-
fields: Record<string, BetterAuthTableField>;
14-
order?: number;
15-
};
16-
17-
export type BetterAuthAuthTables = Record<string, BetterAuthTableDef>;
7+
/** Schema type returned by better-auth's getSchema function */
8+
type BetterAuthSchema = Record<string, { fields: Record<string, DBFieldAttribute>; order: number }>;
189

1910
function normalizeBetterAuthFieldType(fieldType: unknown): string {
2011
if (typeof fieldType === "string") return fieldType;
@@ -46,7 +37,7 @@ export async function getMetadata(fetch: ReturnType<typeof createRawFetch>["fetc
4637

4738
export async function planMigration(
4839
fetch: ReturnType<typeof createRawFetch>["fetch"],
49-
betterAuthSchema: BetterAuthAuthTables,
40+
betterAuthSchema: BetterAuthSchema,
5041
databaseName: string,
5142
): Promise<MigrationPlan> {
5243
const metadata = await getMetadata(fetch, databaseName);
@@ -104,7 +95,7 @@ export async function planMigration(
10495
.sort((a, b) => (a[1].order ?? 0) - (b[1].order ?? 0))
10596
.map(([key, value]) => ({
10697
...value,
107-
keyName: key,
98+
modelName: key, // Use the key as modelName since getSchema uses table names as keys
10899
}));
109100

110101
const migrationPlan: MigrationPlan = [];

0 commit comments

Comments
 (0)