import { getResourceTypeOptions, getResourceTypePermissions } from "../schema-resources.js";

//#region src/cli/commands/plugin/create/resource-defaults.ts
/**
* Resource type and permission defaults for plugin scaffolding.
* Values are derived from plugin-manifest.schema.json via schema-resources.
*/
const MANIFEST_SCHEMA_ID = "https://databricks.github.io/appkit/schemas/plugin-manifest.schema.json";
/** Resource types from schema resourceType enum (value, human label). */
const RESOURCE_TYPE_OPTIONS = getResourceTypeOptions();
/** All valid permissions per resource type, from schema allOf/if-then rules. */
const PERMISSIONS_BY_TYPE = getResourceTypePermissions();
/** Default (first) permission per resource type for scaffolding. */
const DEFAULT_PERMISSION_BY_TYPE = Object.fromEntries(Object.entries(PERMISSIONS_BY_TYPE).map(([type, perms]) => [type, perms[0]]));
/** Default fields per resource type: field key -> { env, description }. */
const DEFAULT_FIELDS_BY_TYPE = {
	sql_warehouse: { id: {
		env: "DATABRICKS_WAREHOUSE_ID",
		description: "SQL Warehouse ID"
	} },
	secret: {
		scope: {
			env: "SECRET_SCOPE",
			description: "Secret scope name"
		},
		key: {
			env: "SECRET_KEY",
			description: "Secret key"
		}
	},
	job: { id: {
		env: "DATABRICKS_JOB_ID",
		description: "Job ID"
	} },
	serving_endpoint: { id: {
		env: "DATABRICKS_SERVING_ENDPOINT_ID",
		description: "Serving endpoint ID"
	} },
	volume: { name: {
		env: "VOLUME_NAME",
		description: "Volume name"
	} },
	vector_search_index: {
		endpoint_name: {
			env: "VECTOR_SEARCH_ENDPOINT_NAME",
			description: "Vector search endpoint name"
		},
		index_name: {
			env: "VECTOR_SEARCH_INDEX_NAME",
			description: "Vector search index name"
		}
	},
	uc_function: { name: {
		env: "UC_FUNCTION_NAME",
		description: "Unity Catalog function name"
	} },
	uc_connection: { name: {
		env: "UC_CONNECTION_NAME",
		description: "Unity Catalog connection name"
	} },
	database: {
		instance_name: {
			env: "DATABRICKS_INSTANCE_NAME",
			description: "Databricks instance name"
		},
		database_name: {
			env: "DATABASE_NAME",
			description: "Database name"
		}
	},
	genie_space: { id: {
		env: "GENIE_SPACE_ID",
		description: "Genie Space ID"
	} },
	experiment: { id: {
		env: "MLFLOW_EXPERIMENT_ID",
		description: "MLflow experiment ID"
	} },
	app: { id: {
		env: "DATABRICKS_APP_ID",
		description: "Databricks App ID"
	} }
};
/** Humanized alias from resource type (e.g. sql_warehouse -> "SQL Warehouse"). */
function humanizeResourceType(type) {
	const option = RESOURCE_TYPE_OPTIONS.find((o) => o.value === type);
	return option ? option.label : type.replace(/_/g, " ");
}
/** Kebab-case resource key from type (e.g. sql_warehouse -> "sql-warehouse"). */
function resourceKeyFromType(type) {
	return type.replace(/_/g, "-");
}
/** Get default fields for a resource type; fallback to single id field. */
function getDefaultFieldsForType(type) {
	const known = DEFAULT_FIELDS_BY_TYPE[type];
	if (known) return known;
	return { id: {
		env: `DATABRICKS_${resourceKeyFromType(type).toUpperCase().replace(/-/g, "_")}_ID`,
		description: `${humanizeResourceType(type)} ID`
	} };
}

//#endregion
export { MANIFEST_SCHEMA_ID, PERMISSIONS_BY_TYPE, RESOURCE_TYPE_OPTIONS, getDefaultFieldsForType, humanizeResourceType, resourceKeyFromType };
//# sourceMappingURL=resource-defaults.js.map