Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function isProcedure(obj: PgEntity): obj is PgProc {
return obj.kind === PgEntityKind.PROCEDURE;
}
}
export type PgSmartTagSupportedKinds =
| PgEntityKind.CLASS
| PgEntityKind.ATTRIBUTE
| PgEntityKind.CONSTRAINT
| PgEntityKind.PROCEDURE;
const meaningByKind: {
[kind in PgSmartTagSupportedKinds]: string;
} = {
[PgEntityKind.CLASS]:
"for tables, composite types, views and materialized views",
[PgEntityKind.ATTRIBUTE]: "for columns/attributes (of any 'class' type)",
[PgEntityKind.CONSTRAINT]: "for table constraints",
[PgEntityKind.PROCEDURE]: "for functions/procedures",
};
const validKinds = Object.entries(meaningByKind)
.map(([kind, meaning]) => `'${kind}' (${meaning})`)
.join(", ");
function compileRule(
rule: PgSmartTagRule
): CompiledPgSmartTagRule {
const { kind, match: incomingMatch, ...rest } = rule;
if (!Object.prototype.hasOwnProperty.call(meaningByKind, kind)) {
throw new Error(
`makePgSmartTagsPlugin rule has invalid kind '${kind}'; valid kinds are: ${validKinds}`
);
}