PHP 8.2.30
Preview: Property.js Size: 2.07 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/@adminjs/prisma/lib/Property.js

import { BaseProperty } from 'adminjs';
import { DATA_TYPES } from './utils/data-types.js';
export class Property extends BaseProperty {
    column;
    enums;
    columnPosition;
    // eslint-disable-next-line default-param-last
    constructor(column, columnPosition = 0, enums) {
        const path = column.name;
        super({ path });
        this.column = column;
        this.enums = enums;
        this.columnPosition = columnPosition;
    }
    isEditable() {
        return !this.isId() && this.column.name !== 'createdAt' && this.column.name !== 'updatedAt';
    }
    isId() {
        return !!this.column.isId;
    }
    name() {
        return this.column.name;
    }
    isRequired() {
        return this.column.isRequired;
    }
    isSortable() {
        return this.type() !== 'reference';
    }
    reference() {
        const isRef = this.column.kind !== 'scalar' && !!this.column.relationName;
        if (isRef) {
            return this.column.type;
        }
        return null;
    }
    referencedColumnName() {
        if (!this.reference())
            return null;
        return this.column.relationToFields?.[0] ?? null;
    }
    foreignColumnName() {
        if (!this.reference())
            return null;
        return this.column.relationFromFields?.[0] ?? null;
    }
    availableValues() {
        if (!this.isEnum())
            return null;
        const enumSchema = this.enums[this.column.type];
        if (!enumSchema)
            return null;
        return enumSchema.values.map((value) => String(value.name)) ?? [];
    }
    position() {
        return this.columnPosition || 0;
    }
    isEnum() {
        return this.column.kind === 'enum';
    }
    type() {
        let type = DATA_TYPES[this.column.type];
        if (this.reference()) {
            type = 'reference';
        }
        if (this.isEnum()) {
            type = 'string';
        }
        // eslint-disable-next-line no-console
        if (!type) {
            console.warn(`Unhandled type: ${this.column.type}`);
        }
        return type;
    }
}
//# sourceMappingURL=Property.js.map

Directory Contents

Dirs: 1 × Files: 15

Name Size Perms Modified Actions
utils DIR
- drwxr-xr-x 2026-02-28 00:28:58
Edit Download
486 B lrw-r--r-- 2026-02-28 00:28:54
Edit Download
1.01 KB lrw-r--r-- 2026-02-28 00:27:46
Edit Download
1.07 KB lrw-r--r-- 2026-02-28 00:28:38
Edit Download
2.97 KB lrw-r--r-- 2026-02-28 00:28:58
Edit Download
2.87 KB lrw-r--r-- 2026-02-28 00:28:08
Edit Download
569 B lrw-r--r-- 2026-02-28 00:28:42
Edit Download
735 B lrw-r--r-- 2026-02-28 00:28:58
Edit Download
2.07 KB lrw-r--r-- 2026-02-28 00:28:14
Edit Download
2.19 KB lrw-r--r-- 2026-02-28 00:28:44
Edit Download
2.01 KB lrw-r--r-- 2026-02-28 00:29:00
Edit Download
7.07 KB lrw-r--r-- 2026-02-28 00:28:18
Edit Download
7.14 KB lrw-r--r-- 2026-02-28 00:28:44
Edit Download
222 B lrw-r--r-- 2026-02-28 00:29:00
Edit Download
44 B lrw-r--r-- 2026-02-28 00:28:22
Edit Download
102 B lrw-r--r-- 2026-02-28 00:28:46
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).