"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.stateSchemaByVersion = exports.emptyState = void 0; var _configSchema = require("@kbn/config-schema"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ /** * WARNING: Do not modify the existing versioned schema(s) below, instead define a new version (ex: 2, 3, 4). * This is required to support zero-downtime upgrades and rollbacks. See https://github.com/elastic/kibana/issues/155764. * * As you add a new schema version, don't forget to change latestTaskStateSchema variable to reference the latest schema. * For example, changing stateSchemaByVersion[1].schema to stateSchemaByVersion[2].schema. */ const stateSchemaByVersion = { 1: { // A task that was created < 8.10 will go through this "up" migration // to ensure it matches the v1 schema. up: state => ({ lastExecutionTimestamp: state.lastExecutionTimestamp || undefined, runs: state.runs || 0, hits: typeof state.hits === 'number' ? state.hits : undefined }), schema: _configSchema.schema.object({ lastExecutionTimestamp: _configSchema.schema.maybe(_configSchema.schema.string()), runs: _configSchema.schema.number(), hits: _configSchema.schema.maybe(_configSchema.schema.number()) }) } }; exports.stateSchemaByVersion = stateSchemaByVersion; const latestTaskStateSchema = stateSchemaByVersion[1].schema; const emptyState = { lastExecutionTimestamp: undefined, runs: 0, hits: undefined }; exports.emptyState = emptyState;