import { type CommonReservedFields, type NoReservedFields, defaultGqlPermission, defaultPermission, } from "@tailor-platform/erp-kit/core"; import { db, type TailorAnyDBField } from "@tailor-platform/sdk"; const builtins = { // Stable, unique, machine-facing identifier bound by calculation, premium determination, and pay mapping key: db .string() .unique() .description("Stable machine-facing identifier; immutable once referenced by any rule"), // Normalized time-type category key, referenced by key never by display name. Not a fixed enum: // the calculation strategy defines the category vocabulary (e.g. WORK, OVERTIME_BEYOND_STATUTORY, // NIGHT, HOLIDAY_STATUTORY for the JP strategy), so other jurisdictions can use their own keys. category: db .string() .description("Normalized time-type category key used by calculation and premium determination"), // UI-only label; never load-bearing for calculation displayName: db .string() .description("Human-facing label for UI only; carries no calculation semantics"), // Stable seam to a downstream (future) payroll earnings code payMapKey: db .string() .description("Stable key mapping this code to a downstream pay/earnings code"), }; type ReservedFields = keyof typeof builtins | CommonReservedFields; export interface CreateTimeEntryCodeTypeParams> { fields?: NoReservedFields; } export function createTimeEntryCodeType>( params: CreateTimeEntryCodeTypeParams, ) { return db .table("TimeEntryCode", { ...builtins, ...((params.fields ?? {}) as F), ...db.fields.timestamps(), }) .permission(defaultPermission) .gqlPermission(defaultGqlPermission); } export const timeEntryCode = createTimeEntryCodeType({});