src/generated/dag-schema-fields.tstypescript
/*!
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

// AUTO-GENERATED by scripts/generate-dag-schema.mjs — do not edit by hand.
// Source: schema/dag-schema.json, vendored from
// airflow-core/src/airflow/serialization/schema.json.
//
// Re-run with: pnpm run generate:dag-schema

/**
 * Dag-level authoring fields, from the curated allowlist in
 * scripts/generate-dag-schema.mjs resolved against the "dag" definition.
 *
 * Every field is optional: leaving one unset means the scheduler applies its
 * own default, so `{}` stays a valid spec and a field added here later cannot
 * break an existing call site.
 */
export interface GeneratedDagFields {
  /** When the Dag runs: `"@once"`, `"@continuous"`, a cron expression, or unset for no schedule. The serializer lowers it onto the schema's `timetable` object. */
  readonly schedule?: string;
  /** Maps to the schema key `description`. */
  readonly description?: string;
  /** Maps to the schema key `start_date`. */
  readonly startDate?: Date;
  /** Maps to the schema key `end_date`. */
  readonly endDate?: Date;
  /** Maps to the schema key `tags`. */
  readonly tags?: readonly string[];
  /** Maps to the schema key `dag_display_name`. */
  readonly dagDisplayName?: string;
  /** Maps to the schema key `doc_md`. */
  readonly docMd?: string;
  /** Maps to the schema key `max_active_tasks`. */
  readonly maxActiveTasks?: number;
  /** Maps to the schema key `max_active_runs`. */
  readonly maxActiveRuns?: number;
  /** Maps to the schema key `max_consecutive_failed_dag_runs`. */
  readonly maxConsecutiveFailedDagRuns?: number;
  /** Maps to the schema key `dagrun_timeout`, in seconds. */
  readonly dagrunTimeout?: number;
  /** Maps to the schema key `catchup`. */
  readonly catchup?: boolean;
  /** Maps to the schema key `fail_fast` (schema default `false`). */
  readonly failFast?: boolean;
  /** Maps to the schema key `render_template_as_native_obj` (schema default `false`). */
  readonly renderTemplateAsNativeObj?: boolean;
  /** Maps to the schema key `disable_bundle_versioning`. */
  readonly disableBundleVersioning?: boolean;
  /** Maps to the schema key `is_paused_upon_creation`. */
  readonly isPausedUponCreation?: boolean;
}

/**
 * Task-level authoring fields, from the scalar properties of the "operator"
 * definition that the author rather than the serializer owns.
 *
 * Optional on the same terms as {@link GeneratedDagFields}.
 */
export interface GeneratedTaskFields {
  /** Maps to the schema key `owner` (schema default `"airflow"`). */
  readonly owner?: string;
  /** Maps to the schema key `start_date`. */
  readonly startDate?: Date;
  /** Maps to the schema key `end_date`. */
  readonly endDate?: Date;
  /** Maps to the schema key `trigger_rule` (schema default `"all_success"`). */
  readonly triggerRule?: string;
  /** Maps to the schema key `depends_on_past` (schema default `false`). */
  readonly dependsOnPast?: boolean;
  /** Maps to the schema key `ignore_first_depends_on_past` (schema default `false`). */
  readonly ignoreFirstDependsOnPast?: boolean;
  /** Maps to the schema key `wait_for_past_depends_before_skipping` (schema default `false`). */
  readonly waitForPastDependsBeforeSkipping?: boolean;
  /** Maps to the schema key `wait_for_downstream` (schema default `false`). */
  readonly waitForDownstream?: boolean;
  /** Maps to the schema key `retries` (schema default `0`). */
  readonly retries?: number;
  /** Maps to the schema key `queue` (schema default `"default"`). */
  readonly queue?: string;
  /** Maps to the schema key `pool` (schema default `"default_pool"`). */
  readonly pool?: string;
  /** Maps to the schema key `pool_slots` (schema default `1`). */
  readonly poolSlots?: number;
  /** Maps to the schema key `execution_timeout`, in seconds. */
  readonly executionTimeout?: number;
  /** Maps to the schema key `retry_delay`, in seconds (schema default `300`). */
  readonly retryDelay?: number;
  /** Maps to the schema key `retry_exponential_backoff` (schema default `0`). */
  readonly retryExponentialBackoff?: number;
  /** Maps to the schema key `max_retry_delay`, in seconds. */
  readonly maxRetryDelay?: number;
  /** Maps to the schema key `priority_weight` (schema default `1`). */
  readonly priorityWeight?: number;
  /** Maps to the schema key `weight_rule` (schema default `"downstream"`). */
  readonly weightRule?: string;
  /** Maps to the schema key `executor`. */
  readonly executor?: string;
  /** Maps to the schema key `do_xcom_push` (schema default `true`). */
  readonly doXcomPush?: boolean;
  /** Maps to the schema key `email_on_failure` (schema default `true`). */
  readonly emailOnFailure?: boolean;
  /** Maps to the schema key `email_on_retry` (schema default `true`). */
  readonly emailOnRetry?: boolean;
  /** Maps to the schema key `doc_md`. */
  readonly docMd?: string;
  /** Maps to the schema key `map_index_template`. */
  readonly mapIndexTemplate?: string;
  /** Maps to the schema key `max_active_tis_per_dag`. */
  readonly maxActiveTisPerDag?: number;
  /** Maps to the schema key `max_active_tis_per_dagrun`. */
  readonly maxActiveTisPerDagrun?: number;
}

/** How a field is carried in the serialized Dag. `datetime` is fractional
 *  seconds since the epoch and `timedelta` is seconds; both are written as
 *  numbers. */
export type SchemaFieldType =
  "string" | "number" | "boolean" | "string[]" | "datetime" | "timedelta";

/** What the serializer needs to know about one authoring field. */
export interface SchemaField {
  /** The key this field takes in the serialized Dag. */
  readonly key: string;
  readonly type: SchemaFieldType;
  /** The schema's default, absent when it declares none. A value equal to it
   *  can be omitted, as Python's BaseSerialization omits what the scheduler
   *  re-derives. */
  readonly default?: string | number | boolean;
  /** Set when the serializer derives `key` from this field rather than
   *  writing the value straight through. */
  readonly virtual?: boolean;
}

/** Schema key, wire type and default of every {@link GeneratedDagFields} field. */
export const DAG_SCHEMA_FIELDS = {
  schedule: { key: "timetable", type: "string", virtual: true },
  description: { key: "description", type: "string" },
  startDate: { key: "start_date", type: "datetime" },
  endDate: { key: "end_date", type: "datetime" },
  tags: { key: "tags", type: "string[]" },
  dagDisplayName: { key: "dag_display_name", type: "string" },
  docMd: { key: "doc_md", type: "string" },
  maxActiveTasks: { key: "max_active_tasks", type: "number" },
  maxActiveRuns: { key: "max_active_runs", type: "number" },
  maxConsecutiveFailedDagRuns: { key: "max_consecutive_failed_dag_runs", type: "number" },
  dagrunTimeout: { key: "dagrun_timeout", type: "timedelta" },
  catchup: { key: "catchup", type: "boolean" },
  failFast: { key: "fail_fast", type: "boolean", default: false },
  renderTemplateAsNativeObj: {
    key: "render_template_as_native_obj",
    type: "boolean",
    default: false,
  },
  disableBundleVersioning: { key: "disable_bundle_versioning", type: "boolean" },
  isPausedUponCreation: { key: "is_paused_upon_creation", type: "boolean" },
} as const satisfies Readonly<Record<keyof GeneratedDagFields, SchemaField>>;

/** Schema key, wire type and default of every {@link GeneratedTaskFields} field. */
export const TASK_SCHEMA_FIELDS = {
  owner: { key: "owner", type: "string", default: "airflow" },
  startDate: { key: "start_date", type: "datetime" },
  endDate: { key: "end_date", type: "datetime" },
  triggerRule: { key: "trigger_rule", type: "string", default: "all_success" },
  dependsOnPast: { key: "depends_on_past", type: "boolean", default: false },
  ignoreFirstDependsOnPast: {
    key: "ignore_first_depends_on_past",
    type: "boolean",
    default: false,
  },
  waitForPastDependsBeforeSkipping: {
    key: "wait_for_past_depends_before_skipping",
    type: "boolean",
    default: false,
  },
  waitForDownstream: { key: "wait_for_downstream", type: "boolean", default: false },
  retries: { key: "retries", type: "number", default: 0 },
  queue: { key: "queue", type: "string", default: "default" },
  pool: { key: "pool", type: "string", default: "default_pool" },
  poolSlots: { key: "pool_slots", type: "number", default: 1 },
  executionTimeout: { key: "execution_timeout", type: "timedelta" },
  retryDelay: { key: "retry_delay", type: "timedelta", default: 300 },
  retryExponentialBackoff: { key: "retry_exponential_backoff", type: "number", default: 0 },
  maxRetryDelay: { key: "max_retry_delay", type: "timedelta" },
  priorityWeight: { key: "priority_weight", type: "number", default: 1 },
  weightRule: { key: "weight_rule", type: "string", default: "downstream" },
  executor: { key: "executor", type: "string" },
  doXcomPush: { key: "do_xcom_push", type: "boolean", default: true },
  emailOnFailure: { key: "email_on_failure", type: "boolean", default: true },
  emailOnRetry: { key: "email_on_retry", type: "boolean", default: true },
  docMd: { key: "doc_md", type: "string" },
  mapIndexTemplate: { key: "map_index_template", type: "string" },
  maxActiveTisPerDag: { key: "max_active_tis_per_dag", type: "number" },
  maxActiveTisPerDagrun: { key: "max_active_tis_per_dagrun", type: "number" },
} as const satisfies Readonly<Record<keyof GeneratedTaskFields, SchemaField>>;

/** The `__version` the serializer stamps into a serialized Dag. The schema
 *  constrains it only to a positive integer, so it is pinned here and guarded
 *  by a test in airflow-core. */
export const SERIALIZATION_VERSION = 3;