chore: relocate backend into apps/api ahead of monorepo merge

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-24 12:20:40 +08:00
co-authored by Claude Sonnet 5
parent af44598df6
commit eaa6d2276a
388 changed files with 0 additions and 13998 deletions
@@ -0,0 +1,62 @@
// 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"
},
},
badge_labels: {
type: "array",
itemShape: "string",
},
};
// ─── 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,
};