// models/advertisements/advertisements.attributes.js // ─── Exclude sets ───────────────────────────────────────────────────────────── // Fields hidden from all roles (internal/denormalized details) const excludeAttributes = [ "image_asset_id", // internal FK, "image" association exposes the resolved asset instead ]; // Admins see everything except the base excludes const adminExclude = [ ...excludeAttributes, ]; // Regular users also cannot see audit trails, soft-delete info, or click metrics const userExclude = [ ...excludeAttributes, "click_count", "createdBy", "updatedBy", "deletedBy", "deletedAt", ]; // ─── JSONB schemas ────────────────────────────────────────────────────────── // Describes shape of the `ctas` JSONB column for paginate's coercion/validation step. const jsonbSchemas = { ctas: { type: "array", itemShape: { label: "string", link: "string", variant: "string", // "default" | "outline" }, }, }; // ─── Computed attributes ────────────────────────────────────────────────────── // Add any SQL-computed fields here (e.g. a "is_currently_live" derived flag). // Format: { key, label, type, order, literal } const computedAttributes = [ // Example: // { // key: "is_live", // label: "Currently Live", // type: "boolean", // order: 99, // literal: `("Advertisement"."is_active" = true AND "Advertisement"."start_date" <= NOW() AND ("Advertisement"."end_date" IS NULL OR "Advertisement"."end_date" >= NOW()))`, // }, ]; module.exports = { excludeAttributes, adminExclude, userExclude, jsonbSchemas, computedAttributes, };