better-auth-studio 1.0.58 → 1.0.59-beta.2

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":"AAOA,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,CAk8KR"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAOA,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,CAo9KR"}
package/dist/routes.js CHANGED
@@ -4354,15 +4354,26 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4354
4354
  const fields = table.fields
4355
4355
  ?.filter((f) => f.name.trim())
4356
4356
  .map((field) => {
4357
- let attrStr = `type: "${field.type}"`;
4358
- if (field.required)
4359
- attrStr += ',\n required: true';
4360
- if (field.unique)
4361
- attrStr += ',\n unique: true';
4357
+ const attrs = [`type: "${field.type}"`];
4358
+ // Always include required (default to false)
4359
+ attrs.push(`required: ${field.required ? 'true' : 'false'}`);
4360
+ // Always include unique (default to false)
4361
+ attrs.push(`unique: ${field.unique ? 'true' : 'false'}`);
4362
+ // Always include input (default to false)
4363
+ attrs.push('input: false');
4364
+ // Add defaultValue for boolean fields
4365
+ if (field.type === 'boolean') {
4366
+ attrs.push('defaultValue: false');
4367
+ }
4368
+ const attrStr = attrs.join(',\n ');
4362
4369
  return ` ${field.name}: {\n ${attrStr}\n }`;
4363
4370
  })
4364
4371
  .join(',\n') || '';
4365
- return ` ${table.name}: {
4372
+ // If extending an existing table, use the extended table name
4373
+ const tableName = table.isExtending && table.extendedTableName
4374
+ ? table.extendedTableName.trim()
4375
+ : table.name.trim();
4376
+ return ` ${tableName}: {
4366
4377
  fields: {
4367
4378
  ${fields}
4368
4379
  },
@@ -4425,7 +4436,6 @@ ${fields}
4425
4436
  }),
4426
4437
  }`;
4427
4438
  });
4428
- // Generate middleware
4429
4439
  const middlewareCode = middleware
4430
4440
  .map((mw) => {
4431
4441
  return ` {
@@ -4462,7 +4472,7 @@ ${fields}
4462
4472
  return ` ${sanitizedName}: createAuthEndpoint(
4463
4473
  "${endpointPath}",
4464
4474
  {
4465
- method: "${endpoint.method || 'POST'}" as const,
4475
+ method: "${endpoint.method || 'POST'}",
4466
4476
  },
4467
4477
  async (ctx) => {
4468
4478
  // ${endpoint.name || sanitizedName}
@@ -4537,8 +4547,8 @@ ${formattedHandlerLogic}
4537
4547
  imports.push('import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api"');
4538
4548
  }
4539
4549
  const serverPluginBody = pluginParts.length > 0
4540
- ? ` id: "${camelCaseName}" as const,\n${pluginParts.join(',\n')}`
4541
- : ` id: "${camelCaseName}" as const`;
4550
+ ? ` id: "${camelCaseName}",\n${pluginParts.join(',\n')}`
4551
+ : ` id: "${camelCaseName}"`;
4542
4552
  const serverPluginCode = cleanCode(`import type { BetterAuthPlugin } from "@better-auth/core";
4543
4553
  ${imports.join('\n')}
4544
4554
 
@@ -4578,7 +4588,7 @@ import type { ${camelCaseName} } from "..";
4578
4588
 
4579
4589
  export const ${camelCaseName}Client = () => {
4580
4590
  return {
4581
- id: "${camelCaseName}" as const,
4591
+ id: "${camelCaseName}",
4582
4592
  $InferServerPlugin: {} as ReturnType<typeof ${camelCaseName}>,${pathMethods ? `\n pathMethods: {\n${pathMethods}\n },` : ''}${atomListenersCode}
4583
4593
  } satisfies BetterAuthClientPlugin;
4584
4594
  };