import { getAuthId } from './auth.js';
export { PluginCommonV1 as PluginCommon } from '@superblocksteam/types';
// The DTO for the full datasource (ie all fields). This should only be visible
// to users that can configure the datasource.
export class DatasourceDto {
    id;
    name;
    pluginId;
    pluginName;
    organizationId;
    configuration;
    //TODO(alex): delete configurationProd, configurationStaging once we change an interface between UI and server
    // @deprecated use configurationProfiles instead
    configurationProd;
    // @deprecated use configurationProfiles instead
    configurationStaging;
    configurationProfiles;
    isDefault;
    creator;
    demoIntegrationId;
    ownerEmail;
    error;
    constructor(datasource, ownerEmail, configurationProfiles) {
        this.id = datasource.id;
        this.name = datasource.name;
        this.pluginId = datasource.pluginId;
        this.organizationId = datasource.organizationId;
        this.demoIntegrationId = datasource.demoIntegrationId;
        this.configuration = datasource.configurationProd;
        this.configurationProd = datasource.configurationProd;
        this.configurationStaging = datasource.configurationStaging;
        this.configurationProfiles = configurationProfiles;
        this.isDefault = datasource.isDefault;
        this.ownerEmail = ownerEmail;
    }
}
// ViewDatasourceDto is just the information needed to use a datasource to
// create steps of that type. Credentials are explicitly excluded - those should
// only be needed to execute the step.
export class ViewDatasourceDto {
    id;
    name;
    pluginId;
    organizationId;
    isDefault;
    readOnly;
    ownerEmail;
    constructor(datasource, readOnly, ownerEmail) {
        this.id = datasource.id;
        this.name = datasource.name;
        this.pluginId = datasource.pluginId;
        this.organizationId = datasource.organizationId;
        this.isDefault = datasource.isDefault;
        this.readOnly = readOnly;
        this.ownerEmail = ownerEmail;
    }
}
export function getAuthIdFromConfig(integrationId, config) {
    if (config.authType) {
        return getAuthId(config.authType, config.authConfig, integrationId);
    }
    return 'empty-auth-type';
}
export var SharedSSHAuthMethod;
(function (SharedSSHAuthMethod) {
    SharedSSHAuthMethod[SharedSSHAuthMethod["PASSWORD"] = 0] = "PASSWORD";
    SharedSSHAuthMethod[SharedSSHAuthMethod["PUB_KEY_RSA"] = 1] = "PUB_KEY_RSA";
    SharedSSHAuthMethod[SharedSSHAuthMethod["PUB_KEY_ED25519"] = 2] = "PUB_KEY_ED25519";
    SharedSSHAuthMethod[SharedSSHAuthMethod["USER_PRIVATE_KEY"] = 3] = "USER_PRIVATE_KEY";
})(SharedSSHAuthMethod || (SharedSSHAuthMethod = {}));
export function isAuthenticatedDatasourceConfig(dc) {
    if (!('authConfig' in dc)) {
        return false;
    }
    return 'authType' in dc && dc.authType !== undefined;
}
export function isAuthenticatedDatasourceConfigWithDynamicAuthType(dc) {
    if (!('authConfig' in dc)) {
        return false;
    }
    if ('authTypeField' in dc &&
        dc.authTypeField &&
        dc[dc.authTypeField] !== undefined &&
        dc[dc.authTypeField] !== null &&
        dc[dc.authTypeField] !== '') {
        return true;
    }
    return false;
}
/**
 * Safely extracts the authType from an authenticated datasource configuration.
 * This function handles both direct authType fields and authTypeField references.
 *
 * @param dc - The datasource configuration
 * @returns The authType if available, undefined otherwise
 */
export function getAuthTypeFromConfig(dc) {
    if (isAuthenticatedDatasourceConfig(dc)) {
        return dc.authType;
    }
    else if (isAuthenticatedDatasourceConfigWithDynamicAuthType(dc)) {
        return dc[dc.authTypeField];
    }
    return undefined;
}
export var DatasourceEnvironments;
(function (DatasourceEnvironments) {
    DatasourceEnvironments["PRODUCTION"] = "Production";
    DatasourceEnvironments["STAGING"] = "Staging";
    DatasourceEnvironments["DEV"] = "Dev";
})(DatasourceEnvironments || (DatasourceEnvironments = {}));
export const ENVIRONMENT_PRODUCTION = 'production';
export const ENVIRONMENT_STAGING = 'staging'; // Only for V1 orgs, V2 orgs use ENVIRONMENT_DEV
export const ENVIRONMENT_DEV = 'dev';
export const ENVIRONMENT_ALL = '*';
export const VALID_DATASOURCE_ENVIRONMENTS = [ENVIRONMENT_PRODUCTION, ENVIRONMENT_DEV, ENVIRONMENT_STAGING, ENVIRONMENT_ALL];
export * from './auth.js';
export * from './metadata/index.js';
export * from './test.js';
//# sourceMappingURL=index.js.map