import type { Attribute } from "../../../attributes/types"; import type { Dataset } from "../../../datasets/types"; import type { PolicyMatchResult, PolicySqlFragments } from "../types"; import type { JsonSchemaConnectorPolicy } from "./json-schema-types"; import type { PolicyBranchMatch } from "./policy-branches"; /** * JSON-Schema-based equivalent of PolicyMatchResult, but instead of fully-built SQL, * it carries branch-level matches that your existing SQL builder can consume. */ export interface JsonSchemaPolicyMatchResult { /** Names of policies whose JSON Schemas were compatible with the dataset. */ appliedPolicies: string[]; /** Policies that were skipped because validation failed. */ skippedPolicies: PolicyMatchResult["skippedPolicies"]; /** Non-fatal warnings (e.g. some policies were skipped). */ warnings: string[]; /** * The minimum refresh schedule (most frequent) across all applied policies, * expressed as an ISO 8601 duration string. */ refresh_schedule: string; /** * For each applied policy, which branches matched and what filters/attributes * they require. This is what your SQL builder layer should consume. */ branchMatches: Array<{ policyName: string; branches: PolicyBranchMatch[]; }>; } /** * Categorize JSON-Schema-based connector policies into matching and non-matching * groups based on dataset compatibility. * * @param policies - JSON-Schema-based connector policies. * @param dataset - Dataset whose schema is used for validation. * @param attributes - Attributes associated with the dataset. * @returns Object with matching policies, nonMatching policies, and skip details. */ export declare function categorizePolicies(policies: JsonSchemaConnectorPolicy[], dataset: Dataset, attributes: Attribute[]): { matching: JsonSchemaConnectorPolicy[]; nonMatching: JsonSchemaConnectorPolicy[]; skippedDetails: PolicyMatchResult["skippedPolicies"]; }; /** * Helper that evaluates JSON-Schema-based policies and returns branch-level * matches plus scheduling information. * * This is intended to be consumed by a separate SQL builder layer or for * inspection of branch-level match details. * * @param dataset - The dataset against which policies should be evaluated. * @param policies - JSON-Schema-based connector policies. * @param attributes - Attributes associated with the dataset. * @returns JsonSchemaPolicyMatchResult with applied/skipped policies and branch matches. * @throws If no policies are compatible with the dataset. */ export declare function buildPolicySqlWithJsonSchema(dataset: Dataset, policies: JsonSchemaConnectorPolicy[], attributes: Attribute[]): JsonSchemaPolicyMatchResult; /** * Uses JSON Schema branch matching to determine valid policies, then builds * SELECT and WHERE SQL fragments. * * @param dataset - Dataset for which to evaluate policies and produce SQL. * @param policies - JSON-Schema-based connector policies. * @param attributes - Attributes associated with the dataset. * @returns PolicyMatchResult with select, where, applied/skipped policies, warnings, and refresh schedule. */ export declare function buildPolicySqlWithValidation(dataset: Dataset, policies: JsonSchemaConnectorPolicy[], attributes: Attribute[]): PolicyMatchResult; /** * Build SQL fragments without validation. Assumes you already filtered the policies * however you want (e.g. via categorizePolicies). Builds SELECT and WHERE SQL * fragments from all provided policies. * * @param dataset - Dataset for which to build SQL fragments. * @param policies - JSON-Schema-based connector policies. * @param attributes - Attributes associated with the dataset. * @returns PolicySqlFragments with select and where arrays. */ export declare function buildPolicySql(dataset: Dataset, policies: JsonSchemaConnectorPolicy[], attributes: Attribute[]): PolicySqlFragments;