import '@stacksjs/validation'; export type { PrunableOptions } from './utils/prunable'; export type { AuditHelpers } from './traits/audit'; // Re-export soft-delete option types so user code can `satisfies SoftDeleteOptions`. export type { SoftDeleteOptions, SoftDeleteHelpers } from './traits/soft-deletes'; export type * from './api-routes'; export type { GenerateSchemaOptions, GenerateSchemaResult } from './generate-database-schema'; export type { CursorPaginator, Paginator, SimplePaginator } from './paginator'; export type { ResolvedPageArgs } from './paginator-request'; // Re-export type utilities from bun-query-builder so consumers can infer // model types directly from defineModel() definitions export type { InferAttributes, InferPrimaryKey, InferRelationNames, InferTableName, ModelDefinition, } from '@stacksjs/query-builder'; /** * Returns a Proxy that lazily forwards every property access to the * loaded model in `_loaded[name]`. Returns `undefined` before the * deferred load completes — callers that need the load to finish * first should `await ormReady`. */ declare function lazyModel(name: string): T; /** * Resolves once all framework-default models have been loaded into the * lazy-export proxies. Server bootstrap code that wants to ensure model * exports are populated before serving the first request should * `await ormReady` early. Per-request code doesn't need to — by the * time any HTTP handler runs, the microtask queue has long drained. */ export declare const ormReady: Promise; export declare const User: ReturnType>; // Queue framework models. The CLI commands `buddy queue:status`, // `queue:failed`, `queue:flush`, `queue:inspect`, `queue:monitor`, // `queue:clear` import them as `import { Job, FailedJob } from // '@stacksjs/orm'`. Prefer the userland publication // (`app/Models/Job.ts`, dropped in by `buddy publish:model Job`) so // projects that customize the queue model see their version. // // Gated on the 'queue' feature flag — projects that don't run a queue // (most marketing sites, plain CMS apps) leave it off and skip the // defineModel pipeline for these two entirely. The lazyModel proxy // returns `undefined` for unloaded models, and the CLI queue commands // can check `await ormReady; if (!Job) throw …` to surface a clear // "run ./buddy queue:install" error. export declare const Job: ReturnType>; export declare const FailedJob: ReturnType>; export declare const Activity: ReturnType>; export declare const AnalyticsEvent: ReturnType>; export declare const Automation: ReturnType>; export declare const AutomationRun: ReturnType>; export declare const Auction: ReturnType>; export declare const CampaignVariant: ReturnType>; export declare const CommunicationSuppression: ReturnType>; export declare const ConsentEvent: ReturnType>; export declare const SenderDomain: ReturnType>; export declare const UsageEvent: ReturnType>; export declare const AuctionItem: ReturnType>; export declare const Author: ReturnType>; export declare const Bid: ReturnType>; export declare const Board: ReturnType>; export declare const BoardColumn: ReturnType>; export declare const Campaign: ReturnType>; export declare const Card: ReturnType>; export declare const CardComment: ReturnType>; export declare const Cart: ReturnType>; export declare const CartItem: ReturnType>; export declare const Category: ReturnType>; export declare const Comment: ReturnType>; export declare const Coupon: ReturnType>; export declare const Customer: ReturnType>; export declare const DeliveryRoute: ReturnType>; export declare const DeliveryStop: ReturnType>; export declare const Deployment: ReturnType>; export declare const DigitalDelivery: ReturnType>; export declare const Driver: ReturnType>; export declare const DriverPing: ReturnType>; export declare const CampaignSend: ReturnType>; export declare const EmailList: ReturnType>; export declare const EmailListSubscriber: ReturnType>; export declare const Form: ReturnType>; export declare const FormField: ReturnType>; export declare const FormSubmission: ReturnType>; export declare const MagicLinkToken: ReturnType>; export declare const Menu: ReturnType>; export declare const MenuItem: ReturnType>; export declare const PageRevision: ReturnType>; export declare const Pledge: ReturnType>; export declare const Redirect: ReturnType>; export declare const Site: ReturnType>; export declare const SiteDomain: ReturnType>; export declare const SmsOptOut: ReturnType>; export declare const EmailIdempotency: ReturnType>; export declare const EmailSuppression: ReturnType>; export declare const EmailWebhookEvent: ReturnType>; export declare const ErrorModel: ReturnType>; export declare const GiftCard: ReturnType>; export declare const Label: ReturnType>; export declare const LicenseKey: ReturnType>; export declare const Log: ReturnType>; export declare const LoyaltyPoint: ReturnType>; export declare const LoyaltyReward: ReturnType>; export declare const MailPreference: ReturnType>; export declare const Manufacturer: ReturnType>; export declare const Notification: ReturnType>; export declare const NotificationDelivery: ReturnType>; export declare const Order: ReturnType>; export declare const OrderIdempotency: ReturnType>; export declare const OrderItem: ReturnType>; export declare const Page: ReturnType>; export declare const Payment: ReturnType>; export declare const PaymentMethod: ReturnType>; export declare const PaymentProduct: ReturnType>; export declare const PaymentTransaction: ReturnType>; export declare const Post: ReturnType>; export declare const PrintDevice: ReturnType>; export declare const Product: ReturnType>; export declare const ProductUnit: ReturnType>; export declare const ProductVariant: ReturnType>; export declare const QueryLog: ReturnType>; export declare const Receipt: ReturnType>; export declare const Release: ReturnType>; export declare const Request: ReturnType>; export declare const Review: ReturnType>; export declare const ShippingMethod: ReturnType>; export declare const ShippingRate: ReturnType>; export declare const ShippingZone: ReturnType>; export declare const SocialPost: ReturnType>; export declare const SocialAccount: ReturnType>; export declare const Subscriber: ReturnType>; export declare const SubscriberEmail: ReturnType>; export declare const Subscription: ReturnType>; export declare const Tag: ReturnType>; export declare const TaxRate: ReturnType>; export declare const Team: ReturnType>; export declare const TeamInvitation: ReturnType>; export declare const TeamMember: ReturnType>; export declare const Transaction: ReturnType>; export declare const WaitlistProduct: ReturnType>; export declare const WaitlistRestaurant: ReturnType>; export declare const Websocket: ReturnType>; /** * A model record seen only through `get(column)`. * * Normalizers, dashboard aggregators and report builders all take rows from * more than one model and read a handful of shared columns by name. Typing * that parameter as the model's own record ties the helper to one model; * typing it as `{ get: (key: string) => unknown }` is WIDER than what any real * record offers, and contravariance then makes every real record unassignable. * * Four copies of this interface had grown up in the dashboard scaffold - one * each for jobs, kanban, analytics and deployments - all with the same * hard-won `any`. This is that type, once. */ export declare interface ReadableRecord { get: (key: any) => unknown } /** * Framework-default User row shape. Matches the attributes declared on * `storage/framework/defaults/app/Models/User.ts` plus the system * fields contributed by `useUuid` / `useTimestamps` / `useAuth` traits. * * For project-specific narrowing, prefer `ModelRow` so * any added attributes flow through automatically. */ export declare interface UserModel { id: number uuid: string name: string email: string password: string avatar?: string | null email_verified_at?: string | null two_factor_secret?: string | null public_key?: string | null created_at: string updated_at: string | null stripe_id?: string | null two_factor_enabled?: boolean hasStripeId: () => boolean hasRole: (role: string) => boolean | Promise assignRole: (role: string) => unknown | Promise update: (data: Record) => Promise [key: string]: unknown } /** * Framework-default insertable User shape — fillable attributes from * the default User model, all optional (DB-side defaults can fill in * the rest). For project-specific narrowing, prefer * `NewModelData`. */ export declare interface NewUser { name?: string email?: string password?: string avatar?: string | null [key: string]: unknown } /** Row type for the polymorphic categories table (categorizable trait). */ export declare interface CategorizableTable { id?: number name: string slug: string description?: string is_active: boolean categorizable_type: string created_at?: string updated_at?: string } /** Row type for the category-model pivot table (categorizable trait). */ export declare interface CategorizableModelsTable { id?: number category_id: number categorizable_type: string categorizable_id: number created_at?: string updated_at?: string } /** Row type for the polymorphic comments table (commentable trait). */ export declare interface CommentablesTable { id?: number title: string body: string status: string approved_at: number | null rejected_at: number | null commentables_id: number commentables_type: string user_id: number | null created_at?: string updated_at?: string | null } /** Row type for the polymorphic tags table (taggable trait). */ export declare interface TaggableTable { id?: number name: string slug: string description?: string is_active: boolean taggable_type: string created_at?: string updated_at?: string } export * from './utils/prunable'; export { collectEncryptedAttributes, decryptValue, encryptValue, isEncrypted, } from './utils/encrypted'; // Audit trait public API: setAuditUser is the queue/cron escape hatch for // attributing audit rows to a user when there's no current HTTP request. export { setAuditUser, createAuditMethods } from './traits/audit'; // The polymorphic trait factories, alongside audit's. `define-model` already // pulls these in, and they are the documented surface for the trait methods — // there was no way to reach them except a subpath import that never resolved, // since only the `@stacksjs/orm` barrel itself is aliased. export { createCommentableMethods } from './traits/commentable'; export { createTaggableMethods } from './traits/taggable'; export { createCategorizableMethods } from './traits/categorizable'; export { createLikeableMethods } from './traits/likeable'; // Shared write-error classifiers (stacksjs/stacks#1957). Named exports only — // `export *` would collide with the snakeCase helpers also exported from // './auto-crud' via other barrels. `isUniqueViolation` is re-exported by // `@stacksjs/auth`'s './rbac-store-bqb' for back-compat; `mapWriteError` // powers the auto-CRUD store/update 409 mapping. export { filterFillable, getWritableFields, isUniqueViolation, mapWriteError, toSnakeCaseKeys } from './auto-crud'; export * from './batch-loader'; export * from './db'; export * from './subquery'; export * from './transaction'; export * from './model-types'; export * from './types'; export * from './utils'; export * from './define-model'; export * from './extend-model'; // Codegen for `database/types.d.ts` — augments // `@stacksjs/database`'s `DatabaseSchema` so `db.selectFrom(...)` gets // table-name autocomplete (stacksjs/stacks#1923). export { buildDatabaseSchema, renderDatabaseTypeFile } from './generate-database-schema'; // Canonical paginator shapes + adapters (stacksjs/stacks#1905 P1). export { isCursorPaginator, isPaginator, isSimplePaginator, toCursorPaginator, toPaginator, toSimplePaginator, } from './paginator'; // Request-aware pagination helpers (stacksjs/stacks#1906 P2 + #1907 P3). export { enrichPaginatorUrls, parseCursor, resolveCursorArgs, resolvePageArgs, } from './paginator-request';