Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
}
if (attribute) {
process(
kind,
identifier,
PgEntityKind.ATTRIBUTE,
attribute,
"attribute"
);
}
if (constraint) {
process(
kind,
identifier,
PgEntityKind.CONSTRAINT,
constraint,
"constraint"
);
}
}
}
return rules;
}
export function isConstraint(obj: PgEntity): obj is PgConstraint {
return obj.kind === PgEntityKind.CONSTRAINT;
}
description?: string;
}
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}`
);
}