import { faker } from '@faker-js/faker';
import { ProjectKind, DomainFileKind, CertificateFileKind, FolderKind, ApiFileKind } from '../../models/kinds.js';
import { File as CoreFile } from '../../models/store/File.js';
import { nanoid } from '../../nanoid.js';
export class File {
    /**
     * Generates a random file object.
     * Note that this generator doesn't create the permissions object. Use Permission class for that.
     * @param init Optional values to be present in the object.
     * @returns Random file
     */
    file(init = {}) {
        const { kind = faker.helpers.arrayElement([ProjectKind, DomainFileKind, CertificateFileKind, ApiFileKind]), info = { name: faker.system.fileName() }, } = init;
        return CoreFile.createSchema({ kind, info });
    }
    /**
     * Generates a list of random file objects.
     * @param size Number of files to generate. Default is 25.
     * @returns List of random files
     */
    files(size = 25) {
        const result = [];
        for (let i = 0; i < size; i++) {
            result.push(this.file());
        }
        return result;
    }
    /**
     * Generates a random folder object.
     * @param init Optional values to be present in the object.
     * @returns Random folder
     */
    folder(init = {}) {
        return this.file({ kind: FolderKind, ...init });
    }
    /**
     * Generates a list of random folder objects.
     * @param size Number of folders to generate. Default is 25.
     * @returns List of random folders
     */
    folders(size = 25) {
        const result = [];
        for (let i = 0; i < size; i++) {
            result.push(this.folder());
        }
        return result;
    }
    /**
     * Generates a random file breadcrumb object.
     * @param size Optional depth of the breadcrumb. Default is random between 2-3.
     * @returns Random file breadcrumb
     */
    fileBreadcrumbs(size) {
        const depth = size ?? 2 + Math.floor(Math.random() * 2); // 2-3
        const items = [];
        for (let i = 0; i < depth; i += 1) {
            const kind = i === depth - 1
                ? faker.helpers.arrayElement([ProjectKind, DomainFileKind, CertificateFileKind, ApiFileKind])
                : FolderKind;
            items.push({ key: nanoid(), kind, name: faker.system.fileName() });
        }
        return items;
    }
}
//# sourceMappingURL=File.js.map