// @ts-check
/**
* Normalized visibility scope helpers.
*
* The Visible table materializes `visible | changeable | admin` rows; the
* business scope is decided by ObjectBase.Type of the TARGET object. Target
* types that participate in the generic visible/changeable filter rebuild are
* listed here.
*
* Projects always participate. Accounting target types (account, fiscalyear,
* costcenter) participate only while NORMALIZED_VISIBLE_SCOPES is enabled - the
* legacy Visible.Accounting column remains the active mechanism otherwise.
*/
import { NORMALIZED_VISIBLE_SCOPES } from '../config/featureFlags.js';
/** Legacy generic list-type targets that already used the visibilityList path. */
export const LEGACY_GENERIC_TARGETS = ['list', 'dlist', 'email', 'event', 'eventT', 'location'];
/** Project scope (new feature, always active). */
export const PROJECT_TARGETS = ['project'];
/**
* Share scope. Shares tragen keine eigenen Filter: sie **spiegeln** den
* Filter-Satz ihres Projekts (./../../RouterProject/projectShare/access.js) und
* werden ueber denselben Rebuild materialisiert. Sie muessen deshalb im
* generischen Ziel-Set stehen — sonst wuerde ein Personen-Rebuild die
* Share-Zeilen der Person nicht nachziehen.
*/
export const SHARE_TARGETS = ['repositoryShare', 'directoryShare'];
/** Accounting target objects (normalized transition, flag-gated). */
export const ACCOUNTING_TARGETS = ['account', 'fiscalyear', 'costcenter'];
/** The full set of target types handled by the generic visible/changeable path. */
export const GENERIC_VISIBLE_TARGETS = (() => {
const set = new Set([...LEGACY_GENERIC_TARGETS, ...PROJECT_TARGETS, ...SHARE_TARGETS]);
if (NORMALIZED_VISIBLE_SCOPES) {
for (const t of ACCOUNTING_TARGETS) set.add(t);
}
return set;
})();
/**
* Build a SQL IN (...) list of quoted literals from a type set.
* @param {Set<string>|string[]} types
* @returns {string}
*/
export const typesIn = (types) => {
const values = [...types];
if (values.length === 0) {
return "('__none__')";
}
return `('${values.join("','")}')`;
};