Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
}
rules.push({
kind,
match: identifier,
tags,
description,
});
if (columns) {
// This was in graphile-utils 4.0.0 but was deprecated in 4.0.1 for consistency reasons.
process(
kind,
identifier,
PgEntityKind.ATTRIBUTE,
columns,
"columns",
true
);
}
if (attribute) {
process(
kind,
identifier,
PgEntityKind.ATTRIBUTE,
attribute,
"attribute"
);
}
if (constraint) {
process(
tags?: PgSmartTagTags;
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}`
);
export function isAttribute(obj: PgEntity): obj is PgAttribute {
return obj.kind === PgEntityKind.ATTRIBUTE;
}