import type { Schema } from 'mongoose'; import type { GetModelTypeFromClass, GetModelTypeLiteFromSchema } from '../modules/BaseModel.ts'; import { BaseModel } from '../modules/BaseModel.ts'; export type TLock = GetModelTypeFromClass; declare class Lock extends BaseModel { static initHooks(schema: Schema): void; static get modelSchema(): { readonly _id: { readonly type: StringConstructor; readonly required: true; }; readonly expiredAt: { readonly type: DateConstructor; }; }; static get modelStatics(): { /** * acquire lock based on lock name * @param {string} name * @param {number} [ttlSeconds=30] */ readonly acquireLock: (this: GetModelTypeLiteFromSchema<{ readonly _id: { readonly type: StringConstructor; readonly required: true; }; readonly expiredAt: { readonly type: DateConstructor; }; }, {}>, name: string, ttlSeconds?: number) => Promise; /** * release lock based on lock name * @param {string} name */ readonly releaseLock: (this: GetModelTypeLiteFromSchema<{ readonly _id: { readonly type: StringConstructor; readonly required: true; }; readonly expiredAt: { readonly type: DateConstructor; }; }, {}>, name: string) => Promise; /** * wait lock based on lock name * @param {string} name */ readonly waitForUnlock: (this: GetModelTypeLiteFromSchema<{ readonly _id: { readonly type: StringConstructor; readonly required: true; }; readonly expiredAt: { readonly type: DateConstructor; }; }, {}>, name: string) => Promise; /** * get lock remaining time based on lock name * @param {string} name */ readonly getLockData: (this: GetModelTypeLiteFromSchema<{ readonly _id: { readonly type: StringConstructor; readonly required: true; }; readonly expiredAt: { readonly type: DateConstructor; }; }, {}>, name: string) => Promise<{ ttl: number; }>; /** * get lock remaining time based on lock name * @param {string[]} names */ readonly getLocksData: (this: GetModelTypeLiteFromSchema<{ readonly _id: { readonly type: StringConstructor; readonly required: true; }; readonly expiredAt: { readonly type: DateConstructor; }; }, {}>, names: string[]) => Promise<{ name: string; ttl: number; }[]>; }; } export default Lock;