"use strict";
/**
 * Organization version-based feature gating module.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrgFeature = exports.OrgVersion = void 0;
exports.orgHasFeature = orgHasFeature;
/**
 * Organization version constants.
 * - V1: Legacy organizations (version "1")
 * - V2: New organizations (version "2")
 *
 * Note: The distinction between cloud-prem and hybrid-cloud deployments is
 * determined by the SUPERBLOCKS_DEPLOYMENT_TYPE environment variable, not the org version.
 */
exports.OrgVersion = {
    V1: '1',
    V2: '2'
};
/**
 * Features that can be gated by organization version.
 */
var OrgFeature;
(function (OrgFeature) {
    OrgFeature["LegacyAuditLogs"] = "LegacyAuditLogs";
    OrgFeature["LegacyObservability"] = "LegacyObservability";
    OrgFeature["LegacySourceControl"] = "LegacySourceControl";
    OrgFeature["LegacySuperblocksOcr"] = "LegacySuperblocksOcr";
    OrgFeature["LegacySuperblocksEmail"] = "LegacySuperblocksEmail";
    OrgFeature["LegacyGoogleSheets"] = "LegacyGoogleSheets";
    OrgFeature["LegacyExecutionToken"] = "LegacyExecutionToken";
    OrgFeature["LegacySecretsManagement"] = "LegacySecretsManagement";
    OrgFeature["LegacyStreamingIntegrations"] = "LegacyStreamingIntegrations";
    OrgFeature["InternalLegacyEndpoints"] = "InternalLegacyEndpoints";
    OrgFeature["Workflows"] = "Workflows";
    OrgFeature["ScheduledJobs"] = "ScheduledJobs";
    OrgFeature["LegacyApps"] = "LegacyApps";
    OrgFeature["PublicApps"] = "PublicApps";
    OrgFeature["ReactApps"] = "ReactApps";
    OrgFeature["Knowledge"] = "Knowledge";
})(OrgFeature || (exports.OrgFeature = OrgFeature = {}));
/**
 * Determines if an organization has access to a specific feature based on its version.
 *
 * @param orgVersion - The organization's version ('1' or '2'), or undefined during migration
 * @param feature - The feature to check access for
 * @returns true if the organization has access to the feature
 */
function orgHasFeature(orgVersion, feature) {
    switch (feature) {
        // V1-only features (legacy organizations)
        case OrgFeature.LegacyAuditLogs:
        case OrgFeature.LegacyObservability:
        case OrgFeature.LegacySourceControl:
        case OrgFeature.LegacySuperblocksOcr:
        case OrgFeature.LegacySuperblocksEmail:
        case OrgFeature.LegacyGoogleSheets:
        case OrgFeature.LegacyExecutionToken:
        case OrgFeature.LegacySecretsManagement:
        case OrgFeature.LegacyStreamingIntegrations:
        case OrgFeature.InternalLegacyEndpoints:
        case OrgFeature.Workflows:
        case OrgFeature.ScheduledJobs:
        case OrgFeature.LegacyApps:
        case OrgFeature.PublicApps:
            return orgVersion === exports.OrgVersion.V1;
        // React apps are always available in V2 orgs.
        // V1 orgs can also access React apps, but that's controlled by feature flags
        // checked separately - this function only handles org-version gating.
        case OrgFeature.ReactApps:
        case OrgFeature.Knowledge:
            return orgVersion === exports.OrgVersion.V2;
        default:
            return false;
    }
}
//# sourceMappingURL=index.js.map