mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
49 lines
1.8 KiB
JavaScript
49 lines
1.8 KiB
JavaScript
// models/assets/assets.attributes.js
|
|
|
|
// ─── Exclude sets ─────────────────────────────────────────────────────────────
|
|
|
|
// Fields hidden from all roles (sensitive / internal storage details)
|
|
const excludeAttributes = [
|
|
"checksum", // internal integrity hash, not useful to clients
|
|
"storage_bucket", // internal storage config
|
|
"storage_key", // internal Chibisafe / S3 key
|
|
"deletedBy", // exposed via audit subquery as a name instead
|
|
];
|
|
|
|
// Admins see everything except the base excludes
|
|
const adminExclude = [
|
|
...excludeAttributes,
|
|
];
|
|
|
|
// Regular users also cannot see audit trails or soft-delete info
|
|
const userExclude = [
|
|
...excludeAttributes,
|
|
"uploadedBy",
|
|
"deletedAt",
|
|
];
|
|
|
|
// ─── No JSONB columns on assets ───────────────────────────────────────────────
|
|
// Assets has no JSONB columns so jsonbSchemas stays empty.
|
|
const jsonbSchemas = {};
|
|
|
|
// ─── Computed attributes ──────────────────────────────────────────────────────
|
|
// Add any SQL-computed fields here (e.g. a view count join).
|
|
// Format: { key, label, type, order, literal }
|
|
const computedAttributes = [
|
|
// Example:
|
|
// {
|
|
// key: "viewCount",
|
|
// label: "Views",
|
|
// type: "number",
|
|
// order: 99,
|
|
// literal: `(SELECT COUNT(*) FROM "asset_views" WHERE "asset_views"."asset_id" = "Asset"."asset_id")`,
|
|
// },
|
|
];
|
|
|
|
module.exports = {
|
|
excludeAttributes,
|
|
adminExclude,
|
|
userExclude,
|
|
jsonbSchemas,
|
|
computedAttributes,
|
|
}; |