/** * * * * @see {@link https://github.com/colinhacks/zod} for more information about Zod. */ import { z } from "zod"; import type { Dataset } from "../datasets/types"; import type { components } from "../generated/api-types"; /** * Defines the structure for a budget object. * * @type {z.ZodObject} */ export declare const NqlBudgetObj: z.ZodObject<{ value: z.ZodNumber; currency: z.ZodEnum<{ USD: "USD"; }>; period: z.ZodEnum<{ CALENDAR_MONTH: "CALENDAR_MONTH"; }>; }, z.core.$strip>; /** * Type for NqlBudget object. * * @typedef NqlBudget */ export type NqlBudget = z.infer; /** * A schema object used to validate and infer the structure of NqlQuery. * * @constant {z.ZodObject} NqlQueryObj */ export declare const NqlQueryInputObj: z.ZodObject<{ nql: z.ZodString; data_plane_id: z.ZodOptional>; execution_cluster: z.ZodOptional; }, z.core.$strip>>; compute_pool_id: z.ZodOptional; create_as_view: z.ZodOptional; }, z.core.$strip>; /** * Type for NqlQueryInput object. This is the object that is passed to the NQL API * * @typedef NqlQueryInput */ export type NqlQueryInput = z.infer; /** * A schema object used to validate and infer the structure of NqlPreSelectExpression. * * @constant {z.ZodEnum} NqlPreSelectExpressionObj */ export declare const NqlPreSelectExpressionObj: z.ZodOptional>; export type NqlPreSelectExpression = z.infer; export type NqlField = z.infer; export declare const NqlDatabaseObject: z.ZodString; export type NqlDatabase = z.infer; export declare const NqlTableObject: z.ZodObject<{ database: z.ZodString; table: z.ZodString; }, z.core.$strip>; export type NqlTable = z.infer; export declare const NqlFieldObj: z.ZodObject<{ field: z.ZodString; table: z.ZodObject<{ database: z.ZodString; table: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; export declare const NqlFilterUnaryExpressionObj: z.ZodObject<{ field: z.ZodObject<{ field: z.ZodString; table: z.ZodObject<{ database: z.ZodString; table: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; operator: z.ZodEnum<{ "IS NULL": "IS NULL"; "IS NOT NULL": "IS NOT NULL"; }>; }, z.core.$strip>; export type NqlFilterUnaryExpression = z.infer; declare const NqlExpressionObj: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; export type NqlExpression = z.infer; export declare const NqlFilterBinaryExpressionObj: z.ZodObject<{ left: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; operator: z.ZodEnum<{ ">": ">"; "<": "<"; ">=": ">="; "<=": "<="; "=": "="; IN: "IN"; "NOT IN": "NOT IN"; "!=": "!="; LIKE: "LIKE"; "NOT LIKE": "NOT LIKE"; }>; right: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; }, z.core.$strip>; export declare const NqlFilterExpressionObj: z.ZodUnion; }, z.core.$strip>; operator: z.ZodEnum<{ "IS NULL": "IS NULL"; "IS NOT NULL": "IS NOT NULL"; }>; }, z.core.$strip>, z.ZodObject<{ left: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; operator: z.ZodEnum<{ ">": ">"; "<": "<"; ">=": ">="; "<=": "<="; "=": "="; IN: "IN"; "NOT IN": "NOT IN"; "!=": "!="; LIKE: "LIKE"; "NOT LIKE": "NOT LIKE"; }>; right: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; }, z.core.$strip>]>; export type NqlFilterExpression = z.infer; export declare const NqlBooleanExpressionObj: z.ZodEnum<{ AND: "AND"; OR: "OR"; }>; export type NqlBooleanExpression = z.infer; export declare const NqlWhereObj: z.ZodObject<{ booleanExpressions: z.ZodArray>; filterExpressions: z.ZodArray; }, z.core.$strip>; operator: z.ZodEnum<{ "IS NULL": "IS NULL"; "IS NOT NULL": "IS NOT NULL"; }>; }, z.core.$strip>, z.ZodObject<{ left: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; operator: z.ZodEnum<{ ">": ">"; "<": "<"; ">=": ">="; "<=": "<="; "=": "="; IN: "IN"; "NOT IN": "NOT IN"; "!=": "!="; LIKE: "LIKE"; "NOT LIKE": "NOT LIKE"; }>; right: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; }, z.core.$strip>]>>; }, z.core.$strip>; export type NqlWhere = z.infer; export type NqlFilterBinaryExpression = z.infer; export declare const NqlObj: z.ZodObject<{ explain: z.ZodOptional>; select: z.ZodArray; }, z.core.$strip>>; from: z.ZodArray>; where: z.ZodObject<{ booleanExpressions: z.ZodArray>; filterExpressions: z.ZodArray; }, z.core.$strip>; operator: z.ZodEnum<{ "IS NULL": "IS NULL"; "IS NOT NULL": "IS NOT NULL"; }>; }, z.core.$strip>, z.ZodObject<{ left: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; operator: z.ZodEnum<{ ">": ">"; "<": "<"; ">=": ">="; "<=": "<="; "=": "="; IN: "IN"; "NOT IN": "NOT IN"; "!=": "!="; LIKE: "LIKE"; "NOT LIKE": "NOT LIKE"; }>; right: z.ZodUnion; }, z.core.$strip>, z.ZodString, z.ZodNumber, z.ZodBoolean]>; }, z.core.$strip>]>>; }, z.core.$strip>; limit: z.ZodObject<{ value: z.ZodNumber; currency: z.ZodEnum<{ USD: "USD"; }>; period: z.ZodEnum<{ CALENDAR_MONTH: "CALENDAR_MONTH"; }>; }, z.core.$strip>; sort: z.ZodOptional; group: z.ZodOptional; having: z.ZodOptional; offset: z.ZodOptional; join: z.ZodOptional; }, z.core.$strip>; export type Nql = z.infer; export interface RelatedJob { id: string; number: number; idempotency_key: string; state: string; compiled_select: string; } export interface BatchInfo { batch_id: string; batch_size: number; related_jobs: RelatedJob[]; } /** * Job state for an NQL run, as returned by `POST /nql/run` and `GET /nql/{id}`. */ export type NqlJobState = "failed" | "cancelled" | "completed" | "pending" | "scheduled" | "pending_cancellation" | "running"; export interface NqlResult { id: string; company_id: number; /** `null` while the job hasn't completed yet. */ completed_at: string | null; created_at: string; failures: unknown[]; input: { nql: string; dataset?: Dataset; /** Present on `EXPLAIN`/forecast runs. */ compiled_sql?: string; /** Present on `CREATE MATERIALIZED VIEW` runs. */ compiled_select?: string; /** Present on `CREATE MATERIALIZED VIEW` runs. */ create_as_view?: boolean; }; idempotency_key: string; request_source: { type: string; company_id: number; user_id: number; }; /** `null`/absent while the job hasn't completed yet. */ result?: { type: string; rows: number; cost: number; nql_type: string; } | null; state: NqlJobState; updated_at: string; chunking_context?: BatchInfo; } export type NqlMappingErrors = Record; export interface NqlCompileResult { sql: string; } export interface ForecastBody { as_of: string; details: QueryDetails; } export interface QueryDetails { type: "marketplace"; pricing: QueryPricing; data_rules: DataRules; } export interface QueryPricing { micro_cents_usd: number; } interface DataRules { attributes: DataRulesAttributes[]; } export interface DataRulesAttributes { fields: DataRulesAttributesField[]; optional: boolean; attribute_id: number; } export interface DataRulesAttributesField { field: string; filter?: FilterDefinition; exported: boolean; } export interface DataRulesAttributesFieldFilter { expression: string[]; } export type FilterDefinition = "include_all_values_including_nulls_filter" | "include_only_if_not_null_filter" | EnumFilter | IntervalFilter | TimestampFilter | SparkSqlConstraintFilter; export interface EnumFilter { type: InclusionType; list: string[]; } export interface IntervalFilter { min?: IntervalEnd; max?: IntervalEnd; } export interface TimestampFilter { recency?: string; from?: IntervalEnd; to?: IntervalEnd; } export interface SparkSqlConstraintFilter { expressions: string[]; } export type IntervalEndType = "inclusive" | "exclusive"; export interface IntervalEnd { type: IntervalEndType; value: string; } export type SpatialPredicate = "contains" | "intersects"; export type InclusionType = "include" | "exclude"; export type AstNodeType = "parsed" | "raw"; export interface AstNodeMetadata { node_type: AstNodeType; version?: string; } /** * Body of `POST /v1/nql/execute`. `create_as_view` applies only to * `CREATE MATERIALIZED VIEW` and is ignored for every other statement. */ export type NqlExecuteRequest = components["schemas"]["ExecuteRequest"]; /** * What `POST /v1/nql/execute` returns: the workflow the statement was compiled * into, plus the id of the run started for it. Poll the run to find out whether * the statement succeeded — the response only says the work was accepted. */ export type NqlExecuteResponse = components["schemas"]["CreateWorkflowResponseWithRunId"]; export {};