/** * This plugin was sponsored by Sprout LLC. 🙏 * * https://sprout.io */ import type { PgSQL, SQL } from "pg-sql2"; import type { FieldArgs, ExecutableStep } from "grafast"; import type { PgCodecWithAttributes, PgRegistry, PgSelectStep } from "@dataplan/pg"; declare global { namespace GraphileBuild { interface Inflection { includeArchivedArgument(this: Inflection, details: { codec: PgCodecWithAttributes; registry: PgRegistry; relationName?: string; }): string; } interface SchemaOptions { /** * The name of the column to use to determine if the record is archived * or not. Defaults to 'is_archived' */ pgArchivedColumnName?: string; /** * Set this true to invert the column logic - i.e. if your column is * `is_visible` instead of `is_archived`. */ pgArchivedColumnImpliesVisible?: boolean; /** * If your determination of whether a record is archived or not is more complex * than checking if a column is not null/not false then you can define an SQL * expression instead. */ pgArchivedExpression?: (sql: PgSQL, tableAlias: SQL) => SQL; /** * The default option to use for the 'includeArchived' argument. Defaults * to 'NO', but will be replaced with 'INHERIT' where possible unless you set * `pgArchivedDefaultInherit` to false. */ pgArchivedDefault?: "INHERIT" | "NO" | "YES" | "EXCLUSIVELY"; /** * Set false if you don't want the system to default to 'INHERIT' if it's * able to do so. */ pgArchivedDefaultInherit?: boolean; /** * Set true if you want related record collections to have the * pg-omit-archived behavior if they belong to a table that explicitly * matches. */ pgArchivedRelations?: boolean; /** * If you want the system to apply the archived filter to a specific list of tables, list their names here: */ pgArchivedTables?: string[]; } interface ScopeObjectFieldsFieldArgs { /** * Set true if child fields should always include archived entries. */ includeArchived?: boolean; } } } declare module "graphile-build-pg" { interface PgCodecRelationTags { archivedRelation?: boolean; } } /** * Build utils * * @param build - Graphile Build object * @param keyword - 'archived' or 'deleted' or similar * @param table - The table we're building a query against * @param parentTable - The table of the `parentQueryBuilder`, if any * @param allowInherit - Should we allow inheritance if it seems possible? */ declare const makeUtils: (build: GraphileBuild.Build, keyword: string, table: PgCodecWithAttributes, parentTable: PgCodecWithAttributes | undefined, allowInherit?: boolean, relevantRelationName?: string | null) => { OptionType: import("graphql").GraphQLNamedType | null | undefined; addWhereClause: ($parent: ExecutableStep, $select: PgSelectStep, fieldArgs: FieldArgs) => void; capableOfInherit: false | ((sql: PgSQL, tableAlias: SQL) => SQL) | { columnName: string; column: import("@dataplan/pg").PgCodecAttribute | undefined, import("@dataplan/pg").PgCodec | undefined, import("@dataplan/pg").PgCodec | undefined>, boolean>; } | undefined, any, any, import("@dataplan/pg").PgCodec | undefined, import("@dataplan/pg").PgCodec | undefined, import("@dataplan/pg").PgCodec | undefined>, boolean>; } | undefined; argumentName: string; } | null; declare const generator: (keyword?: string) => GraphileConfig.Plugin; declare const PgOmitArchivedPlugin: GraphileConfig.Plugin & { custom: (keyword?: string) => GraphileConfig.Plugin; makeUtils: (build: GraphileBuild.Build, keyword: string, table: PgCodecWithAttributes, parentTable: PgCodecWithAttributes | undefined, allowInherit?: boolean, relevantRelationName?: string | null) => { OptionType: import("graphql").GraphQLNamedType | null | undefined; addWhereClause: ($parent: ExecutableStep, $select: PgSelectStep, fieldArgs: FieldArgs) => void; capableOfInherit: false | ((sql: PgSQL, tableAlias: SQL) => SQL) | { columnName: string; column: import("@dataplan/pg").PgCodecAttribute | undefined, import("@dataplan/pg").PgCodec | undefined, import("@dataplan/pg").PgCodec | undefined>, boolean>; } | undefined, any, any, import("@dataplan/pg").PgCodec | undefined, import("@dataplan/pg").PgCodec | undefined, import("@dataplan/pg").PgCodec | undefined>, boolean>; } | undefined; argumentName: string; } | null; }; export default PgOmitArchivedPlugin; export { generator as custom, makeUtils, PgOmitArchivedPlugin };