import { T as TeamDatabase, a as TeamTables, O as OrganizationRow, b as OrganizationMemberRow } from '../access-490O6aOU.js';
export { C as CreateAccessOptions, c as CreateOrganizationAccessOptions, d as CreateTeamTablesOptions, e as OrganizationAccess, f as OrganizationAccessApi, g as TeamParentTable, U as UserWorkspaceSummary, W as WorkspaceAccess, h as WorkspaceAccessApi, i as WorkspaceAccessTable, j as WorkspaceMemberRow, k as createOrganizationAccess, l as createTeamTables, m as createWorkspaceAccess } from '../access-490O6aOU.js';
export { C as CreateWorkspaceInvitationTableOptions, W as WorkspaceInvitationRow, a as WorkspaceInvitationTables, c as createWorkspaceInvitationTable } from '../invitations-schema-_fI7HkJP.js';
import { O as OrganizationRole } from '../roles-B4nU3jDi.js';
import 'drizzle-orm/sqlite-core';

/**
 * `ensurePersonalOrganization` — the substrate that makes solo-user adoption
 * work. Every user gets exactly one auto-created `kind: 'personal'` org with
 * the user as `owner` member. That org is the tenant that owns their
 * workspaces, so role resolution (`getWorkspaceAccess`) has an org row to read
 * even before any team/invite exists.
 *
 * Idempotent by construction: the org `slug` is derived from the user id
 * (`personal-<id>`) and upserted; the membership upserts on the
 * (organizationId, userId) unique index. Concurrent calls converge — no
 * duplicate personal orgs, no duplicate owner rows.
 *
 * ADOPTION CONTRACT: call this once per user at first authenticated entry
 * (e.g. right after sign-in / session bootstrap) BEFORE the first
 * `getWorkspaceAccess`. Role resolution requires the org membership to exist;
 * an adopter that skips this will see `null` access for a brand-new user with
 * no org row. There is no implicit creation inside the access builders — that
 * keeps reads side-effect-free; provisioning is this explicit call.
 */

/** Define the structure for a user within a personal organization context */
interface EnsurePersonalOrganizationUser {
    id: string;
    name?: string | null;
    email?: string | null;
}
/** Describe a personal organization result including organization, member, and role details */
interface PersonalOrganizationResult {
    organization: OrganizationRow;
    member: OrganizationMemberRow;
    role: OrganizationRole;
}
/** Define options required to create a personal organization including database and tables references */
interface CreatePersonalOrganizationOptions {
    db: TeamDatabase;
    tables: TeamTables;
}
/** Ensure a user has a personal organization by creating or retrieving it as needed */
declare function createEnsurePersonalOrganization(opts: CreatePersonalOrganizationOptions): (user: EnsurePersonalOrganizationUser) => Promise<PersonalOrganizationResult>;

export { type CreatePersonalOrganizationOptions, type EnsurePersonalOrganizationUser, OrganizationMemberRow, OrganizationRow, type PersonalOrganizationResult, TeamDatabase, TeamTables, createEnsurePersonalOrganization };
