import { BaseEngine } from "@memberjunction/core";
/**
 * Caches the rows of `MJ: Audit Log Types` so callers that emit audit-log
 * entries can resolve `AuditLogTypeID` by NAME instead of by hardcoded UUID.
 *
 * The seed data (under `metadata/audit-log-types/`) is the source of truth
 * for the IDs — code that hardcodes them goes stale silently if a row is
 * renamed or replaced. Code that calls `ByName(...)` fails loud at the
 * lookup site instead, which is much easier to track down.
 *
 * Singleton via `BaseEngine`. Idempotent `Config()` — subsequent calls
 * short-circuit once the cache is loaded.
 *
 * @example
 * await AuditLogTypeEngine.Instance.Config(false, contextUser, provider);
 * const t = AuditLogTypeEngine.Instance.ByName('List Shared');
 * if (!t) throw new Error('Audit log type "List Shared" not seeded');
 * auditLog.AuditLogTypeID = t.ID;
 */
export class AuditLogTypeEngine extends BaseEngine {
    constructor() {
        super(...arguments);
        this._AuditLogTypes = [];
    }
    static get Instance() {
        return super.getInstance();
    }
    async Config(forceRefresh, contextUser, provider) {
        const c = [
            {
                Type: 'entity',
                EntityName: 'MJ: Audit Log Types',
                PropertyName: '_AuditLogTypes',
                CacheLocal: true,
            },
        ];
        await this.Load(c, provider, forceRefresh, contextUser);
    }
    get AuditLogTypes() {
        return this.GetConfigData('_AuditLogTypes');
    }
    /**
     * Look up a row by exact `Name`. Returns `undefined` if the engine
     * hasn't been configured yet or no row matches — callers should treat
     * the latter as "seed metadata missing" and throw, never silently
     * persist rows with an undefined `AuditLogTypeID`.
     */
    ByName(name) {
        return this._AuditLogTypes.find(t => t.Name === name);
    }
}
//# sourceMappingURL=AuditLogTypeEngine.js.map