Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/objectql/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,14 @@ export class ObjectQL implements IDataEngine {
}

// 3. Check package's defaultDatasource
if (object?.packageId) {
const manifest = this.manifests.get(object.packageId);
const owner = SchemaRegistry.getObjectOwner(objectName);
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SchemaRegistry.getObjectOwner() only looks up by FQN key (it does not resolve short names or physical tableName). In getDriver(), objectName is often the resolved physical table name (via resolveObjectName()), so getObjectOwner(objectName) will usually return undefined and skip package defaultDatasource routing. Use the resolved schema's FQN (object?.name) when calling getObjectOwner, or add a registry helper that resolves owner from any object identifier.

Suggested change
const owner = SchemaRegistry.getObjectOwner(objectName);
const owner = SchemaRegistry.getObjectOwner(object?.name ?? objectName);

Copilot uses AI. Check for mistakes.
if (owner?.packageId) {
const manifest = this.manifests.get(owner.packageId);
if (manifest?.defaultDatasource && manifest.defaultDatasource !== 'default') {
if (this.drivers.has(manifest.defaultDatasource)) {
this.logger.debug('Resolved datasource from package manifest', {
object: objectName,
package: object.packageId,
package: owner.packageId,
datasource: manifest.defaultDatasource
});
return this.drivers.get(manifest.defaultDatasource)!;
Comment on lines +621 to 631
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change alters datasource routing logic but there are no tests asserting that package defaultDatasource resolution works when callers pass a short object name or a physical tableName (both are used elsewhere via resolveObjectName). Adding a focused unit test around getDriver()/find() would prevent regressions in datasource mapping.

Copilot uses AI. Check for mistakes.
Expand Down
22 changes: 13 additions & 9 deletions packages/plugins/plugin-auth/src/auth-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import type { Auth, BetterAuthOptions } from 'better-auth';
import { organization } from 'better-auth/plugins/organization';
import { twoFactor } from 'better-auth/plugins/two-factor';
import { magicLink } from 'better-auth/plugins/magic-link';
import type { AuthConfig } from '@objectstack/spec/system';
import type {
AuthConfig,
EmailAndPasswordConfig,
AuthPluginConfig,
} from '@objectstack/spec/system';
import type { IDataEngine } from '@objectstack/core';
import { createObjectQLAdapterFactory } from './objectql-adapter.js';
import {
Expand Down Expand Up @@ -374,20 +378,20 @@ export class AuthManager {
}

// Extract email/password config (safe fields only)
const emailPasswordConfig = this.config.emailAndPassword || {};
const emailPasswordConfig: Partial<EmailAndPasswordConfig> = this.config.emailAndPassword ?? {};
const emailPassword = {
enabled: emailPasswordConfig.enabled !== false, // Default to true
disableSignUp: emailPasswordConfig.disableSignUp,
requireEmailVerification: emailPasswordConfig.requireEmailVerification,
disableSignUp: emailPasswordConfig.disableSignUp ?? false,
requireEmailVerification: emailPasswordConfig.requireEmailVerification ?? false,
Comment on lines +381 to +385
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EmailAndPasswordConfig is inferred from a Zod .optional() schema (T | undefined). Using Partial<EmailAndPasswordConfig> collapses to {} (because keyof (T | undefined) becomes never), so emailPasswordConfig.enabled/disableSignUp/... will not type-check. Use Partial<NonNullable<EmailAndPasswordConfig>> (or Partial<NonNullable<AuthConfig['emailAndPassword']>>) for the local variable typing.

Copilot uses AI. Check for mistakes.
};

// Extract enabled features
const pluginConfig = this.config.plugins || {};
const pluginConfig: Partial<AuthPluginConfig> = this.config.plugins ?? {};
const features = {
twoFactor: pluginConfig.twoFactor || false,
passkeys: pluginConfig.passkeys || false,
magicLink: pluginConfig.magicLink || false,
organization: pluginConfig.organization || false,
twoFactor: pluginConfig.twoFactor ?? false,
passkeys: pluginConfig.passkeys ?? false,
magicLink: pluginConfig.magicLink ?? false,
organization: pluginConfig.organization ?? false,
};

return {
Expand Down
Loading