graphile-utils
Version:
Utilities to help with building graphile-build plugins
75 lines (74 loc) • 3.04 kB
TypeScript
import type { Plugin, Build } from "graphile-build";
import type { PgEntityKind, PgEntity } from "graphile-build-pg";
export declare type PgSmartTagFilterFunction<T> = (input: T, build: Build) => boolean;
export declare type PgSmartTagTags = {
[tagName: string]: null | true | string | string[];
};
export interface PgSmartTagRule<T extends PgEntity = PgEntity> {
kind: PgEntityKind;
match: string | PgSmartTagFilterFunction<T>;
tags?: PgSmartTagTags;
description?: string;
}
export declare type PgSmartTagSupportedKinds = PgEntityKind.CLASS | PgEntityKind.ATTRIBUTE | PgEntityKind.CONSTRAINT | PgEntityKind.PROCEDURE;
export declare type UpdatePgSmartTagRulesCallback = (ruleOrRules: PgSmartTagRule | PgSmartTagRule[] | null) => void;
export declare type SubscribeToPgSmartTagUpdatesCallback = (cb: UpdatePgSmartTagRulesCallback | null) => void | Promise<void>;
export declare function makePgSmartTagsPlugin(ruleOrRules: PgSmartTagRule | PgSmartTagRule[] | null, subscribeToUpdatesCallback?: SubscribeToPgSmartTagUpdatesCallback | null): Plugin;
/**
* JSON (or JSON5) description of the tags to add to various entities, e.g.
*
* ```js
* {
* version: 1,
* tags: {
* class: {
* my_table: {
* tags: {omit: "create,update,delete"},
* description: "You can overwrite the description too",
* attribute: {
* my_private_field: {tags: {omit: true}}
* },
* constraint: {
* my_constraint: {tags: {omit: true}}
* }
* },
* "my_schema.myOtherTable": {
* description: "If necessary, add your schema to the table name to prevent multiple being matched"
* }
* },
* procedure: {
* "my_schema.my_function_name": {
* tags: {sortable: true, filterable: true}
* }
* }
* }
* }
* ```
*/
export declare type JSONPgSmartTags = {
version: 1;
config: {
[kind in PgSmartTagSupportedKinds]?: {
[identifier: string]: {
tags?: PgSmartTagTags;
description?: string;
attribute?: {
[attributeName: string]: {
tags?: PgSmartTagTags;
description?: string;
};
};
constraint?: {
[constraintName: string]: {
tags?: PgSmartTagTags;
description?: string;
};
};
};
};
};
};
export declare function pgSmartTagRulesFromJSON(json: JSONPgSmartTags | null): PgSmartTagRule[];
export declare type UpdateJSONPgSmartTagsCallback = (json: JSONPgSmartTags | null) => void;
export declare type SubscribeToJSONPgSmartTagsUpdatesCallback = (cb: UpdateJSONPgSmartTagsCallback | null) => void | Promise<void>;
export declare function makeJSONPgSmartTagsPlugin(json: JSONPgSmartTags | null, subscribeToJSONUpdatesCallback?: SubscribeToJSONPgSmartTagsUpdatesCallback | null): Plugin;