import { DataCatalogKind } from './kinds.js';
export class DataCatalog {
    key;
    get kind() {
        return DataCatalogKind;
    }
    organization;
    file;
    scope;
    name;
    description;
    publishedBy;
    publishedAt;
    createdAt;
    updatedAt;
    unpublishedAt;
    deprecated;
    deprecatedAt;
    deprecatedBy;
    deprecationReason;
    tags;
    static createSchema(input) {
        const { key = '', organization = '', file = '', scope = 'private', name = '', description = '', publishedBy = '', publishedAt = 0, createdAt = 0, updatedAt = 0, tags = [], } = input;
        if (['public', 'private', 'organization'].indexOf(scope) === -1) {
            throw new Error(`Invalid scope: ${scope}`);
        }
        const result = {
            key,
            kind: DataCatalogKind,
            organization,
            file,
            scope,
            name,
            description,
            publishedBy,
            publishedAt,
            createdAt,
            updatedAt,
            tags,
        };
        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.deprecationReason === 'string') {
            result.deprecationReason = input.deprecationReason;
        }
        if (typeof input.unpublishedAt === 'number') {
            result.unpublishedAt = input.unpublishedAt;
        }
        return result;
    }
    constructor(input = {}) {
        const init = DataCatalog.createSchema(input);
        this.key = init.key;
        this.organization = init.organization;
        this.file = init.file;
        this.scope = init.scope;
        this.name = init.name;
        this.description = init.description;
        this.publishedBy = init.publishedBy;
        this.publishedAt = init.publishedAt;
        this.createdAt = init.createdAt;
        this.updatedAt = init.updatedAt;
        this.tags = init.tags;
        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: DataCatalogKind,
            organization: this.organization,
            file: this.file,
            scope: this.scope,
            name: this.name,
            description: this.description,
            publishedBy: this.publishedBy,
            publishedAt: this.publishedAt,
            createdAt: this.createdAt,
            updatedAt: this.updatedAt,
            tags: [...this.tags],
        };
        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;
        }
        return result;
    }
}
//# sourceMappingURL=DataCatalog.js.map