import { DataCatalogVersionKind } from './kinds.js';
export class DataCatalogVersion {
    key;
    get kind() {
        return DataCatalogVersionKind;
    }
    catalogKey;
    scope;
    lifecycle;
    version;
    publishedBy;
    unpublishedAt;
    deprecated;
    deprecatedAt;
    deprecatedBy;
    deprecationReason;
    createdAt;
    updatedAt;
    changelog;
    static createSchema(input) {
        const { key = '', scope = 'private', publishedBy = '', createdAt = 0, updatedAt = 0, catalogKey = '', lifecycle = 'stable', version = '', } = input;
        if (['public', 'private', 'organization'].indexOf(scope) === -1) {
            throw new Error(`Invalid scope: ${scope}`);
        }
        const result = {
            key,
            kind: DataCatalogVersionKind,
            scope,
            publishedBy,
            createdAt,
            updatedAt,
            catalogKey,
            lifecycle,
            version,
        };
        if (typeof input.deprecated === 'boolean') {
            result.deprecated = input.deprecated;
        }
        if (typeof input.deprecatedAt === 'number') {
            result.deprecatedAt = input.deprecatedAt;
        }
        if (typeof input.deprecatedBy === 'string') {
            result.deprecatedBy = input.deprecatedBy;
        }
        if (typeof input.changelog === 'string') {
            result.changelog = input.changelog;
        }
        if (typeof input.deprecationReason === 'string') {
            result.deprecationReason = input.deprecationReason;
        }
        if (typeof input.unpublishedAt === 'number') {
            result.unpublishedAt = input.unpublishedAt;
        }
        return result;
    }
    constructor(input = {}) {
        const init = DataCatalogVersion.createSchema(input);
        this.key = init.key;
        this.catalogKey = init.catalogKey;
        this.lifecycle = init.lifecycle;
        this.scope = init.scope;
        this.version = init.version;
        this.publishedBy = init.publishedBy;
        this.createdAt = init.createdAt;
        this.updatedAt = init.updatedAt;
        if (typeof init.changelog === 'string') {
            this.changelog = init.changelog;
        }
        if (typeof init.deprecated === 'boolean') {
            this.deprecated = init.deprecated;
        }
        if (typeof init.deprecatedAt === 'number') {
            this.deprecatedAt = init.deprecatedAt;
        }
        if (typeof init.deprecatedBy === 'string') {
            this.deprecatedBy = init.deprecatedBy;
        }
        if (typeof init.deprecationReason === 'string') {
            this.deprecationReason = init.deprecationReason;
        }
        if (typeof init.unpublishedAt === 'number') {
            this.unpublishedAt = init.unpublishedAt;
        }
    }
    toJSON() {
        const result = {
            key: this.key,
            kind: DataCatalogVersionKind,
            scope: this.scope,
            publishedBy: this.publishedBy,
            createdAt: this.createdAt,
            updatedAt: this.updatedAt,
            catalogKey: this.catalogKey,
            lifecycle: this.lifecycle,
            version: this.version,
        };
        if (typeof this.deprecated === 'boolean') {
            result.deprecated = this.deprecated;
        }
        if (typeof this.deprecatedAt === 'number') {
            result.deprecatedAt = this.deprecatedAt;
        }
        if (typeof this.deprecatedBy === 'string') {
            result.deprecatedBy = this.deprecatedBy;
        }
        if (typeof this.deprecationReason === 'string') {
            result.deprecationReason = this.deprecationReason;
        }
        if (typeof this.unpublishedAt === 'number') {
            result.unpublishedAt = this.unpublishedAt;
        }
        if (typeof this.changelog === 'string' && this.changelog) {
            result.changelog = this.changelog;
        }
        return result;
    }
}
//# sourceMappingURL=DataCatalogVersion.js.map