better-auth-studio 1.0.59-beta.6 → 1.0.59-beta.8

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 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAgBA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAyLhG;AAwBD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAqlLR"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAqLhG;AAeD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAsmLR"}
package/dist/routes.js CHANGED
@@ -11,6 +11,7 @@ import { createMockAccount, createMockSession, createMockUser, createMockVerific
11
11
  import { getAuthData } from './data.js';
12
12
  import { initializeGeoService, resolveIPLocation, setGeoDbPath } from './geo-service.js';
13
13
  import { detectDatabaseWithDialect } from './utils/database-detection.js';
14
+ import { possiblePaths } from './config.js';
14
15
  const config = {
15
16
  N: 16384,
16
17
  r: 16,
@@ -66,7 +67,6 @@ export async function safeImportAuthConfig(authConfigPath, noCache = false) {
66
67
  if (authConfigPath.endsWith('.ts')) {
67
68
  const aliases = {};
68
69
  const authConfigDir = dirname(authConfigPath);
69
- // Find project root by looking for tsconfig.json
70
70
  let projectDir = authConfigDir;
71
71
  let tsconfigPath = join(projectDir, 'tsconfig.json');
72
72
  while (!existsSync(tsconfigPath) && projectDir !== dirname(projectDir)) {
@@ -74,10 +74,8 @@ export async function safeImportAuthConfig(authConfigPath, noCache = false) {
74
74
  tsconfigPath = join(projectDir, 'tsconfig.json');
75
75
  }
76
76
  const content = readFileSync(authConfigPath, 'utf-8');
77
- // Get path aliases from tsconfig (including extends chain)
78
77
  const { getPathAliases } = await import('./config.js');
79
78
  const tsconfigAliases = getPathAliases(projectDir) || {};
80
- // Handle relative imports
81
79
  const relativeImportRegex = /import\s+.*?\s+from\s+['"](\.\/[^'"]+)['"]/g;
82
80
  const dynamicImportRegex = /import\s*\(\s*['"](\.\/[^'"]+)['"]\s*\)/g;
83
81
  const foundImports = new Set();
@@ -111,7 +109,6 @@ export async function safeImportAuthConfig(authConfigPath, noCache = false) {
111
109
  const pathAliasRegex = /import\s+.*?\s+from\s+['"](\$[^'"]+)['"]/g;
112
110
  while ((match = pathAliasRegex.exec(content)) !== null) {
113
111
  const aliasPath = match[1];
114
- // Check if we have a matching alias
115
112
  const aliasBase = aliasPath.split('/')[0];
116
113
  if (tsconfigAliases[aliasBase]) {
117
114
  const remainingPath = aliasPath.replace(aliasBase, '').replace(/^\//, '');
@@ -222,14 +219,6 @@ export async function safeImportAuthConfig(authConfigPath, noCache = false) {
222
219
  async function findAuthConfigPath() {
223
220
  const { join, dirname } = await import('node:path');
224
221
  const { existsSync } = await import('node:fs');
225
- const possiblePaths = [
226
- 'auth.js',
227
- 'auth.ts',
228
- 'src/auth.js',
229
- 'src/auth.ts',
230
- 'lib/auth.js',
231
- 'lib/auth.ts',
232
- ];
233
222
  for (const path of possiblePaths) {
234
223
  const fullPath = join(process.cwd(), path);
235
224
  if (existsSync(fullPath)) {
@@ -4358,7 +4347,28 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4358
4347
  attrs.push(`required: ${field.required ? 'true' : 'false'}`);
4359
4348
  attrs.push(`unique: ${field.unique ? 'true' : 'false'}`);
4360
4349
  attrs.push('input: false');
4361
- if (field.type === 'boolean') {
4350
+ // Handle defaultValue
4351
+ if (field.defaultValue !== undefined && field.defaultValue !== null && field.defaultValue !== '') {
4352
+ if (field.type === 'string') {
4353
+ attrs.push(`defaultValue: "${field.defaultValue}"`);
4354
+ }
4355
+ else if (field.type === 'boolean') {
4356
+ attrs.push(`defaultValue: ${field.defaultValue === 'true' || field.defaultValue === true}`);
4357
+ }
4358
+ else if (field.type === 'number') {
4359
+ attrs.push(`defaultValue: ${field.defaultValue}`);
4360
+ }
4361
+ else if (field.type === 'date') {
4362
+ if (field.defaultValue === 'now()') {
4363
+ attrs.push('defaultValue: new Date()');
4364
+ }
4365
+ else {
4366
+ attrs.push(`defaultValue: new Date("${field.defaultValue}")`);
4367
+ }
4368
+ }
4369
+ }
4370
+ else if (field.type === 'boolean') {
4371
+ // Default to false for boolean if no defaultValue specified
4362
4372
  attrs.push('defaultValue: false');
4363
4373
  }
4364
4374
  const attrStr = attrs.join(',\n ');