import mongoose from 'mongoose'; import { M as MemberResolver, C as Container } from './resolver-DXtfO0qV.js'; import { C as ClockInPlugin, h as EventBus, A as PluginManager, a as PluginContext } from './plugin-BI0AkTzA.js'; import { CheckInService, CheckOutService, AnalyticsService, CorrectionRequestService } from './services/index.js'; import { Logger, ObjectIdLike, DeepPartial, TargetModelConfig } from './types.js'; import './errors/index.js'; /** * ClockIn - Modern Attendance Management * @classytic/clockin * * @example * ```typescript * const clockin = await ClockIn * .create() * .withModels({ Attendance, Membership }) * .withPlugin(loggingPlugin()) * .build(); * * const result = await clockin.checkIn.record({ member, targetModel: 'Membership' }); * ``` */ /** Models configuration */ interface ModelsConfig { Attendance: mongoose.Model; [targetModel: string]: mongoose.Model; } /** Single-tenant configuration */ interface SingleTenantConfig { organizationId?: ObjectIdLike; autoInject?: boolean; } /** ClockIn options */ interface ClockInOptions { debug?: boolean; logger?: Logger; singleTenant?: SingleTenantConfig; } declare class ClockIn { private readonly _container; private readonly _events; private readonly _plugins; private readonly _logger; private readonly _singleTenant?; readonly checkIn: CheckInService; readonly checkOut: CheckOutService; readonly analytics: AnalyticsService; readonly corrections: CorrectionRequestService; private constructor(); static create(options?: ClockInOptions): ClockInBuilder; /** @internal */ static _build(container: Container, events: EventBus, plugins: PluginManager, logger: Logger, singleTenant?: SingleTenantConfig): ClockIn; get container(): Container; get events(): EventBus; get plugins(): PluginManager; get isSingleTenant(): boolean; get singleTenantOrgId(): ObjectIdLike | undefined; on: EventBus['on']; once: EventBus['once']; off: EventBus['off']; createContext(): PluginContext; destroy(): Promise; } declare class ClockInBuilder { private _options; private _models; private _plugins; private _targetConfigs; private _allowedTargetModels; private _memberResolver; private _identifierFields; private _pluginFailFast; constructor(options?: ClockInOptions); withModels(models: ModelsConfig): this; /** * Configure a target model with custom settings. * * Use this to register custom target models or override settings for built-in models. * * @example * ```typescript * ClockIn.create() * .withModels({ Attendance, Event }) * .withTargetModel('Event', { * detection: { type: 'time-based' }, * autoCheckout: { enabled: true, afterHours: 4 } * }) * .build(); * ``` */ withTargetModel(name: string, config: DeepPartial): this; /** * Alias for withTargetModel - register a custom target model with configuration. * * @example * ```typescript * ClockIn.create() * .withModels({ Attendance, Workshop }) * .registerTargetModel('Workshop', { * detection: { type: 'time-based' }, * autoCheckout: { enabled: true, afterHours: 2 } * }) * .build(); * ``` */ registerTargetModel(name: string, config?: DeepPartial): this; /** * Allow any target model (default behavior). * * This explicitly enables the default v2.0 behavior where any non-empty string * is accepted as a target model. Use this for clarity when you want to support * custom target models without restrictions. * * @example * ```typescript * ClockIn.create() * .withModels({ Attendance, Event, Workshop, Membership }) * .allowAnyTargetModel() * .build(); * ``` */ allowAnyTargetModel(): this; /** * Restrict target models to a specific allowlist. * * When configured, only the specified target models will be accepted. * Use this for stricter validation when you know exactly which models * should be supported. * * @example * ```typescript * ClockIn.create() * .withModels({ Attendance, Membership, Employee }) * .restrictTargetModels(['Membership', 'Employee']) * .build(); * ``` */ restrictTargetModels(models: string[]): this; /** * Set a custom member resolver for bulk operations. * * The resolver determines how members are looked up by identifier * in bulk check-in operations. Use this to implement custom lookup * strategies (e.g., by membership code, employee ID, etc.). * * @example * ```typescript * // Custom resolver that looks up by membership code * const models = { Attendance, Membership }; * * const customResolver: MemberResolver = { * async resolve(identifier, targetModel, context) { * const Model = models[targetModel]; * return Model.findOne({ * organizationId: context.organizationId, * membershipCode: identifier, * }); * }, * }; * * ClockIn.create() * .withModels(models) * .withMemberResolver(customResolver) * .build(); * ``` */ withMemberResolver(resolver: MemberResolver): this; /** * Configure the default member resolver with custom identifier fields. * * The default resolver tries each field in order until a member is found. * Use this to customize which fields are searched for member lookup. * * @example * ```typescript * ClockIn.create() * .withModels({ Attendance, Membership }) * .withIdentifierFields(['membershipCode', 'email', 'customer.email']) * .build(); * ``` */ withIdentifierFields(fields: string[]): this; withPlugin(plugin: ClockInPlugin): this; withPlugins(plugins: ClockInPlugin[]): this; /** * Enable fail-fast mode for plugins. * When enabled, the first plugin hook failure will throw an error * instead of logging and continuing. * * @param enabled - Whether to enable fail-fast mode (default: true) */ withPluginFailFast(enabled?: boolean): this; withLogger(logger: Logger): this; forSingleTenant(config?: SingleTenantConfig): this; withDebug(enabled?: boolean): this; build(): Promise; } declare function createClockIn(config: { models: ModelsConfig; options?: ClockInOptions; plugins?: ClockInPlugin[]; targetConfigs?: Record>; }): Promise; export { ClockIn, ClockInBuilder, type ClockInOptions, type ModelsConfig, type SingleTenantConfig, createClockIn, ClockIn as default };